472,969 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,969 software developers and data experts.

Partition view optimization

I vaguely remember seeing that PostgresSQL optimized selects on certain
UNION ALL statements, so that given:

CREATE VIEW orders AS
SELECT '2003-01' as period, * FROM orders_2003_01
UNION ALL
SELECT '2003-02' as period, * FROM orders_2003_02

then

SELECT * FROM orders WHERE period = '2003-01'

would do a full table scan only on the orders_2003_01 table.

But I didn't see this optimization while I was running some tests against
7.4.2.

Am I missing something now? Or am I just mis-remembering Postgres'
behavior?
Jul 19 '05 #1
1 4009
I see now that the partition view optimization kicks in when I explicitly
cast the period to varchar:

CREATE VIEW orders AS
SELECT '2003-01'::varchar as period, * FROM orders_2003_01
UNION ALL
SELECT '2003-02'::varchar as period, * FROM orders_2003_02

Fair enough, although I'm a little puzzled as to why the plan is different
when the 'period' column is a 'varchar' rather than a 'text'.

"Stacy White" <ha***@computer.org> wrote in message
news:ZuApc.56702$z06.7999140@attbi_s01...
I vaguely remember seeing that PostgresSQL optimized selects on certain
UNION ALL statements, so that given:

CREATE VIEW orders AS
SELECT '2003-01' as period, * FROM orders_2003_01
UNION ALL
SELECT '2003-02' as period, * FROM orders_2003_02

then

SELECT * FROM orders WHERE period = '2003-01'

would do a full table scan only on the orders_2003_01 table.

But I didn't see this optimization while I was running some tests against
7.4.2.

Am I missing something now? Or am I just mis-remembering Postgres'
behavior?

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Surendra | last post by:
I have this query that I need to use in an Update statement to populate a field in the table by the value of Sq ---------------------------------------------------------------------------- Inline...
6
by: jota | last post by:
Is there any more hands on way to make a copy of a vector where pred is TRUE.(in the code snip) And I need a copy becourse OnFX might or might not alter List. typedef std::vector<CS *> LIST;...
4
by: Neil | last post by:
I just resolved a strange situation I was having with an ODBC linked SQL 7 view in an Access 2000 MDB file, and I'm trying to get some understanding as to what happened. The linked view was...
2
by: sandi | last post by:
Dear Group, I have the task of designing a table with similar characteristics of Oracle range partitioning. Note: we are migrating from ORacle to DB2 and we have many tables with range...
1
by: Mark Dengler | last post by:
I am trying to write a C# backend program that will handle the database maintenance that I would otherwise have to do via Microsoft's Analysis Services front end GUI Wizards. Currently I am having...
5
by: sameer_deshpande | last post by:
Hi, I need to create a partition table but the column on which I need to create a partition may not have any logical ranges. So while creating or defining partition function I can not use any...
2
by: henryhcface | last post by:
i am so sorry! the english is not my mother language. but i need everyone help actually. it takes 16 seconds to query the this sql SELECT count(*) FROM Sold_Listing_V as slv WHERE...
0
by: Vinod Sadanandan | last post by:
Table Partition Performance analysis ============================================ Collection of Statistics for Cost-Based Optimization/DBMS_STATS vs. ANALYZE The cost-based approach relies on...
0
debasisdas
by: debasisdas | last post by:
SAMPLE CODE TO CREATE SUB PARTITIONS ======================================= RANGE-HASH-9i ------------------------- CREATE TABLE SUBPART ( ID NUMBER(10) PRIMARY KEY, NAME VARCHAR2(20) )
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.