From: | Bill Thoen <bthoen(at)gisnet(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Directing Partitioned Table Searches |
Date: | 2011-02-05 00:35:10 |
Message-ID: | 4D4C9B3E.7030402@gisnet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
In a partitioned table, is it possible to specify the partition for a
query to search using a variable instead of a constant?
EXAMPLE: Join another table to the partitioned one
Table: clu (partitioned by state)
ogc_fid bigint
cluid char(16)
state bpchar(2)
constraint: state='mi' (or 'co', 'ks', etc. for each partition)
Table: farms
link bigint
zone bpchar(2)
farmid char(7)
...
This selection will result in partitions being searched
SELECT cluid, farmid
FROM clu JOIN farms ON ogc_fid=link
This selection will result in only the 'mi' (Michigan) partition being
searched
SELECT cluid, farmid
FROM clu JOIN farms ON ogc_fid=link
WHERE state='mi'
And this selection will result in ALL partitions being searched. But why?
SELECT cluid, farmid
FROM clu JOIN farms ON ogc_fid=link
WHERE state=zone
I'd like to be able to run some queries w/o the overhead of searching
partitions unnecessarily. Can it be done?
Regards,
--
*Bill Thoen*
GISnet - www.gisnet.com <http://www.gisnet.com/>
1401 Walnut St., Suite C
Boulder, CO 80302
303-786-9961 tel
303-443-4856 fax
bthoen(at)gisnet(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | pasman pasmański | 2011-02-05 03:29:37 | Feature: vacuum page before write |
Previous Message | MargaretGillon | 2011-02-04 23:39:47 | CRUD functions, similar to SQL stored procedurs, for postgresql tables? |