I was trying to work around limitations with "partitioning" of tables
using constraint exclusion, when I ran across this little oddity:
-- works
test=# select * from (select time from url_access_2006_06_07 order by 1
limit 2) as ss1; time
--------------------- 2006-06-07 15:07:41 2006-06-07 15:07:41
(2 rows)
-- works
test=# select time from url_access_2006_06_08 order by 1 limit 2; time
--------------------- 2006-06-08 15:07:41 2006-06-08 15:07:41
(2 rows)
-- huh ?!?
test=# select * from (select time from url_access_2006_06_07 order by 1
limit 2) as ss1 union all select time from url_access_2006_06_08 order
by 1 limit 2; time
--------------------- 2006-06-07 15:07:41 2006-06-07 15:07:41
(2 rows)
-- works
test=# select * from (select time from url_access_2006_06_07 order by 1
limit 2) as ss1 union all select * from (select time from
url_access_2006_06_08 order by 1 limit 2) as ss2; time
--------------------- 2006-06-07 15:07:41 2006-06-07 15:07:41 2006-06-08 15:07:41 2006-06-08 15:07:41
(4 rows)
I get an error if I try to eliminate the first FROM clause subselect:
test=# select time from url_access_2006_06_07 order by 1 limit 2 union
all select * from (select time from url_access_2006_06_08 order by 1
limit 2) as ss2;
ERROR: syntax error at or near "all" at character 65
LINE 1: ...om url_access_2006_06_07 order by 1 limit 2 union all select...
So I'm wondering whether the second FROM clause subselect is really
required, but not getting enforced as it should?
Joe