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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:54:46+00:00 2026-05-23T10:54:46+00:00

I have a table that is partitioned by month and is used for holding

  • 0

I have a table that is partitioned by month and is used for holding apache log information. When I run EXPLAIN for a simple query which has a WHERE clause on the same field as the partition CHECKs, I get the same plan whether constraint_exclusion is on or off. Below is the master table info and two examples of child tables info for Feb and Mar of 2010. Overall, there is a child table for each month from Feb of 2010 through June of 2011. On average, each child table has around 100M records. Also below is the output of EXPLAIN for a simple query, once with constraint_exclusion on and once with it off. Unfortunately, the CHECK constraints aren’t being used to reduce the plan size. Is this due to the fact that request_dt datatype is TIMESTAMP WITH TIME ZONE but the CHECK constraints are DATES? Any other thoughts? I have not yet created indexes on request_dt, but according to the documentation that isn’t necessary. I’ll be adding them, but I wouldn’t think they should impact the use of the CHECK constraints.

I’m using Postgres 8.3.6.

spatial_data=# \d rpt.websvcs_logs
                        Table "rpt.websvcs_logs"
          Column          |            Type             |   Modifiers   
--------------------------+-----------------------------+---------------
 id                       | bigint                      | 
 ins_ts                   | timestamp without time zone | default now()
 server                   | text                        | 
 host                     | text                        | 
 request_dt               | timestamp with time zone    | 
 method                   | text                        | 
 url                      | text                        | 
 api_method               | text                        | 
 api_key                  | text                        | 
 geo_type                 | text                        | 
 geo_name                 | text                        | 
 radius                   | text                        | 
 lat                      | text                        | 
 long                     | text                        | 
 id_param                 | text                        | 
 state                    | text                        | 
 max                      | text                        | 
 sort_by                  | text                        | 
 sort_dir                 | text                        | 
 rpp                      | text                        | 
 page                     | text                        | 
 ver                      | text                        | 
 output                   | text                        | 
 http_ver                 | text                        | 
 status                   | text                        | 
 size                     | text                        | 
 x_forwarded_for          | text                        | 
 referrer                 | text                        | 
 agent                    | text                        | 
 accept_encoding          | text                        | 
 processing_time_sec      | text                        | 
 processing_time_microsec | text                        | 


spatial_data=# \d rpt.websvcs_logs_201102
                    Table "rpt.websvcs_logs_201102"
          Column          |            Type             |   Modifiers   
 --------------------------+-----------------------------+---------------
 id                       | bigint                      | not null
 ins_ts                   | timestamp without time zone | default now()
 server                   | text                        | 
 host                     | text                        | 
 request_dt               | timestamp with time zone    | 
 method                   | text                        | 
 url                      | text                        | 
 api_method               | text                        | 
 api_key                  | text                        | 
 geo_type                 | text                        | 
 geo_name                 | text                        | 
 radius                   | text                        | 
 lat                      | text                        | 
 long                     | text                        | 
 id_param                 | text                        | 
 state                    | text                        | 
 max                      | text                        | 
 sort_by                  | text                        | 
 sort_dir                 | text                        | 
 rpp                      | text                        | 
 page                     | text                        | 
 ver                      | text                        | 
 output                   | text                        | 
 http_ver                 | text                        | 
 status                   | text                        | 
 size                     | text                        | 
 x_forwarded_for          | text                        | 
 referrer                 | text                        | 
 agent                    | text                        | 
 accept_encoding          | text                        | 
 processing_time_sec      | text                        | 
 processing_time_microsec | text                        | 
Indexes:
    "pk_websvcs_logs_201102_id" PRIMARY KEY, btree (id)
Check constraints:
    "request_dt" CHECK (request_dt >= '2011-02-01'::date AND request_dt < '2011-03-01'::date)
Inherits: rpt.websvcs_logs


spatial_data=# \d rpt.websvcs_logs_201103
                    Table "rpt.websvcs_logs_201103"
          Column          |            Type             |   Modifiers   
--------------------------+-----------------------------+---------------
 id                       | bigint                      | not null
 ins_ts                   | timestamp without time zone | default now()
 server                   | text                        | 
 host                     | text                        | 
 request_dt               | timestamp with time zone    | 
 method                   | text                        | 
 url                      | text                        | 
 api_method               | text                        | 
 api_key                  | text                        | 
 geo_type                 | text                        | 
 geo_name                 | text                        | 
 radius                   | text                        | 
 lat                      | text                        | 
 long                     | text                        | 
 id_param                 | text                        | 
 state                    | text                        | 
 max                      | text                        | 
 sort_by                  | text                        | 
 sort_dir                 | text                        | 
 rpp                      | text                        | 
 page                     | text                        | 
 ver                      | text                        | 
 output                   | text                        | 
 http_ver                 | text                        | 
 status                   | text                        | 
 size                     | text                        | 
 x_forwarded_for          | text                        | 
 referrer                 | text                        | 
 agent                    | text                        | 
 accept_encoding          | text                        | 
 processing_time_sec      | text                        | 
 processing_time_microsec | text                        | 
Indexes:
    "pk_websvcs_logs_201103_id" PRIMARY KEY, btree (id)
Check constraints:
    "request_dt" CHECK (request_dt >= '2011-03-01'::date AND request_dt < '2011-04-01'::date)
Inherits: rpt.websvcs_logs


spatial_data=# SET constraint_exclusion = on;
SET
spatial_data=# EXPLAIN SELECT COUNT(*) FROM rpt.websvcs_logs WHERE request_dt = DATE '2011-03-05';
                                              QUERY
PLAN                                              
------------------------------------------------------------------------------------------------------
 Aggregate  (cost=85738875.50..85738875.52 rows=1 width=0)
   ->  Append  (cost=0.00..85738236.41 rows=255636 width=0)
         ->  Seq Scan on websvcs_logs  (cost=0.00..11.00 rows=1 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201002 websvcs_logs  (cost=0.00..564425.36 rows=1387 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201003 websvcs_logs  (cost=0.00..1546537.50 rows=4287 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201004 websvcs_logs  (cost=0.00..2528697.60 rows=9248 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201005 websvcs_logs  (cost=0.00..3164403.20 rows=12885 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201006 websvcs_logs  (cost=0.00..4476196.10 rows=12035 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201007 websvcs_logs  (cost=0.00..4470579.60 rows=9543 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201008 websvcs_logs  (cost=0.00..4881312.70 rows=11071 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201009 websvcs_logs  (cost=0.00..4433474.70 rows=11005 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201010 websvcs_logs  (cost=0.00..5419184.20 rows=13605 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201011 websvcs_logs  (cost=0.00..5562311.50 rows=15424 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201012 websvcs_logs  (cost=0.00..5543114.80 rows=14961 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201101 websvcs_logs  (cost=0.00..7320972.20 rows=23008 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201102 websvcs_logs  (cost=0.00..7413710.90 rows=23898 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201103 websvcs_logs  (cost=0.00..8754694.20 rows=27241 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201104 websvcs_logs  (cost=0.00..9292596.80 rows=30848 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201105 websvcs_logs  (cost=0.00..9148734.80 rows=30727 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201106 websvcs_logs  (cost=0.00..1217213.25 rows=4456 width=0)
               Filter: (request_dt = '2011-03-05'::date)



spatial_data=# SET constraint_exclusion = off;
SET
spatial_data=# EXPLAIN SELECT COUNT(*) FROM rpt.websvcs_logs WHERE request_dt = DATE '2011-03-05';
                                              QUERY PLAN                                              
------------------------------------------------------------------------------------------------------
 Aggregate  (cost=85738875.50..85738875.52 rows=1 width=0)
   ->  Append  (cost=0.00..85738236.41 rows=255636 width=0)
         ->  Seq Scan on websvcs_logs  (cost=0.00..11.00 rows=1 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201002 websvcs_logs  (cost=0.00..564425.36 rows=1387 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201003 websvcs_logs  (cost=0.00..1546537.50 rows=4287 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201004 websvcs_logs  (cost=0.00..2528697.60 rows=9248 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201005 websvcs_logs  (cost=0.00..3164403.20 rows=12885 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201006 websvcs_logs  (cost=0.00..4476196.10 rows=12035 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201007 websvcs_logs  (cost=0.00..4470579.60 rows=9543 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201008 websvcs_logs  (cost=0.00..4881312.70 rows=11071 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201009 websvcs_logs  (cost=0.00..4433474.70 rows=11005 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201010 websvcs_logs  (cost=0.00..5419184.20 rows=13605 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201011 websvcs_logs  (cost=0.00..5562311.50 rows=15424 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201012 websvcs_logs  (cost=0.00..5543114.80 rows=14961 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201101 websvcs_logs  (cost=0.00..7320972.20 rows=23008 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201102 websvcs_logs  (cost=0.00..7413710.90 rows=23898 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201103 websvcs_logs  (cost=0.00..8754694.20 rows=27241 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201104 websvcs_logs  (cost=0.00..9292596.80 rows=30848 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201105 websvcs_logs  (cost=0.00..9148734.80 rows=30727 width=0)
               Filter: (request_dt = '2011-03-05'::date)
         ->  Seq Scan on websvcs_logs_201106 websvcs_logs  (cost=0.00..1217213.25 rows=4456 width=0)
               Filter: (request_dt = '2011-03-05'::date)
  • 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-23T10:54:47+00:00Added an answer on May 23, 2026 at 10:54 am

    You must change the type of request_dt column to DATE, or change the check constraints to work with timestamp. In the documentation, you can see an example with a date type column.

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

Sidebar

Related Questions

I have a table that is partitioned by month (partmonth int). The stored proc
I have table that I insert data with following query (from c# code): INSERT
I have a log table that gets processed every night. Processing will be done
I have a partitioned table that belongs to tablespace report . I want to
I have a table that is partitioned by TRANSACTION_DATE_TIME. Table has a column: ID.
I have an Oracle table which contains event log messages for an application. We
I have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45
I have a table that contains multiple dropdown menus for a list of profile
I have a table that looks like this: id value AGA 0.211 AGA 0.433
I have a table that looks like this: CREATE TABLE foobar ( id SERIAL

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.