Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8997243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:51:43+00:00 2026-06-15T23:51:43+00:00

How i should index two timestamp columns (ie starts_at and ends_at ), which would

  • 0

How i should index two timestamp columns (ie starts_at and ends_at), which would be used almost always together in queries (like starts_at >= ? AND ends_at <= ?)? Create composite index for both columns or index each one separatly?

Btw, i’m using Postgres, if it matters 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:51:44+00:00Added an answer on June 15, 2026 at 11:51 pm

    If these two columns are true timestamps with a low number of rows containing precisely the same timestamp, then there really is no use in a composite key, since the range scan would not be able to pick a single value for the first. This can be different if the fields are dates, as frequently dates can match where timestamps don’t. There is a small benefit to it but my experience is that it’s not enormous.

    If you are using a sufficiently large and dense datase (if a single index scan will need to scan a large portion of the index) the query planner can use multiple indexes, combining them with a bitmap.

    http://www.postgresql.org/docs/current/static/indexes-bitmap-scans.html

    As always with this type of question, it’s worth running tests on your dataset.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Should I be careful adding too many include columns to a non-cluster index? I
I am having problems overlaping two boxes. Should I use absolute positioning? z-index or
I have a many-to-many join table in Postgres that I would like to index
My Solr Index has two types of Users( Type-A and Type-B ), which can
I would like to know in which cases a single hashed column with an
I want to index two different OntModel and execute sparql queries on them. For
Suppose you want a Blog with two different layouts. One layout should look like
I need to match up two almost-the-same long freetext strings; i.e., to find index-to-index
I have a boolean flag :finished . Should I A: index({ finished: 1 })
RewriteEngine on RewriteCond %{REQUEST_URI} !^/index\.php RewriteRule ^(.*)$ index.php?q=$1 [L] This should rewrite any url

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.