[SQL] Returning the total number of rows as a separate column when using limit

2007-11-04 Thread Andreas Joseph Krogh
This is a re-post as I didn't get any response last time Hi. AFAICS the information about the *total* number of rows is in the "result" somehow. When I execute a "limit 1" query with EXPLAIN ANALYZE, I se the total number of columns in "ro

[SQL] Partitioning and Foreign Keys

2007-11-04 Thread Volkan YAZICI
Hi, We have a customers database growing ~1,000 rows per day. (Nearly, %40 of the table is garbage and won't get queried that often in the future. But we keep them for statistical analysing purposes of previous jobs.) Despite table allocates relatively small size on the disk, requirement of instan

Re: [SQL] SELECT DISTINCT ... ORDER BY UPPER(column_name) fails

2007-11-04 Thread Tom Lane
Aymeric Levaux <[EMAIL PROTECTED]> writes: > SELECT DISTINCT tag FROM logs ORDER BY UPPER(tag); > You get the following error message : > for SELECT DISTINCT, ORDER BY expressions must appear in select list. > It is weird as the order by column appears in the select. No it doesn't. The ORDER BY

[SQL] SELECT DISTINCT ... ORDER BY UPPER(column_name) fails

2007-11-04 Thread Aymeric Levaux
On pgsql 8.2, if you do the following query, everything is fine: SELECT DISTINCT tag FROM logs ORDER BY tag; But if you'd like to do a case insensitive order by like this: SELECT DISTINCT tag FROM logs ORDER BY UPPER(tag); or SELECT DISTINCT tag FROM logs ORDER BY LOWER(tag); You get the fol

Re: [SQL] omitting redundant join predicate

2007-11-04 Thread Tom Lane
Ehab Galal <[EMAIL PROTECTED]> writes: > explain select * > from t1, t2, t3 > where t1.f <= t2.f > and t2.f <= t3.f > and t1.f <= t3.f; > I was wondering if there is a > way to omit the redundant join predicate. You're not being very clear here. Do you mean will you get the same answer if

[SQL] omitting redundant join predicate

2007-11-04 Thread Ehab Galal
I tried the following query explain select * from t1, t2, t3 where t1.f <= t2.f and t2.f <= t3.f and t1.f <= t3.f; And that's what I got: Nested Loop (cost=0.00..3.15 rows=1 width=368) Join Filter: (("outer".f <= "inner".f) AND ("inner".f <= "outer".f)) -> Nested