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 270857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:04:06+00:00 2026-05-12T00:04:06+00:00

I have situation, where running a query that filters by an indexed column in

  • 0

I have situation, where running a query that filters by an indexed column in a partitioned table, performs a full table scan.

Apparently , this is a known issue in postgresql, and it’s explained in detail here.

Is there a more elegant way around this other than performing a query on each partition, and then performing a UNION on all of the results?

  • 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-05-12T00:04:07+00:00Added an answer on May 12, 2026 at 12:04 am

    Indexes work just fine to do a scan only of the relevant partitions in PostgreSQL. But, you have to set everything up properly for it to work, and it’s easy to miss a step in the long list of things documented at http://www.postgresql.org/docs/current/static/ddl-partitioning.html

    The main thing to realize is that in order to avoid a sequential scan, you have to provide enough information to PostgreSQL so it can prove some partitions cannot have the data you’re looking for; then they are skipped as potential sources for the query results. The article you link to points this out as a solution to the seq scan problem: “If you add range constraints to the date field of each partition, this query can be optimized into a loop where you query the “latest” partition first and work backwards until you find a single value that is higher than the range of all the remaining partitions.”–but doesn’t show the improved plan you’d see after that change.

    Some common mistakes you might have made:

    -The constraint_exclusion parameter in the postgresql.conf file is off by default. With that default, you won’t get what you expect.

    -Didn’t create non-overlapping partitions using CHECK, which keeps the planner from knowing what’s inside each of them. It’s possible to miss this step but still get your data into the right partitions properly, the planner just won’t know that.

    -Did not put an index on each partition, only created one on the master table. This will give you a sequential scan just on the relevant partition, so not as bad as the above but not good either.

    There’s some work to make this all easier in upcoming PostgreSQL releases (setting constraint_partition is fairly automatic in 8.4 and some sort of partition setup automation is being worked in). Right now, if you follow the instructions carefully and avoid all these problems, it should work.

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

Sidebar

Related Questions

I'm in a very, very tight situation here. I have an SQL query running
I have this situation - PhoneGap app running in Android. It uses external API
We have a peculiar situation with a particular query. This query joins to a
I have a query that looks like this: select id , int1 , int2
I have this situation that is really irritating me now. At random times with
I have a situation where I am running in a WCF service that has
I have a situation where user requests to do a long running process. I
I have a situation where i need to send commands to a running java
Here is the situation: You have one long-running calculation running in a background thread.
I have a simulation that uses OpenGL for drawing. While it is running, I

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.