Re: [SQL] group by complications

2006-02-16 Thread Markus Schaber
Hi, Mark, Mark Fenbers schrieb: > Wow! I didn't know you could have a (select ...) as a replacement for a > 'from' table/query. Your SQL worked as-is, except I had to add a 'limit > 1' to the first subquery. > > Thanks! I would have never figured that out on my own! SQL has more power than mo

Re: [SQL] Using EXPLAIN-ANALYZE

2006-02-16 Thread Kashmira Patel \(kupatel\)
Thanks for the explanations and the links. Will try some of this out and come back to you guys if I still don't understand :) -Kashmira -Original Message- From: Andrew Sullivan [mailto:[EMAIL PROTECTED] Sent: Thursday, February 16, 2006 1:14 PM To: Kashmira Patel (kupatel) Cc: Andrew Sul

Re: [SQL] Using EXPLAIN-ANALYZE

2006-02-16 Thread Andrew Sullivan
On Thu, Feb 16, 2006 at 01:08:40PM -0800, Kashmira Patel (kupatel) wrote: > So I would have to put in lots of rows of data in the table before using > the explain command? Well, no, but you won't get useful information without it. PostgreSQL has a cost-based optimizer. The query plan is affecte

Re: [SQL] Using EXPLAIN-ANALYZE

2006-02-16 Thread Owen Jacobson
Kashmira Patel wrote: > So I would have to put in lots of rows of data in the table > before using the explain command? No, but PostgreSQL's query planner may take a different approach for a small table than a large one. The statistics used are generated during VACUUM ANALYZE/VACUUM FULL ope

Re: [SQL] Using EXPLAIN-ANALYZE

2006-02-16 Thread Kashmira Patel \(kupatel\)
So I would have to put in lots of rows of data in the table before using the explain command? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrew Sullivan Sent: Thursday, February 16, 2006 12:39 PM To: pgsql-sql@postgresql.org Subject: Re: [SQL] Using

Re: [SQL] Using EXPLAIN-ANALYZE

2006-02-16 Thread Abhishek
http://www.postgresql.org/docs/7.2/static/performance-tips.html   EXPLAIN is explaied quite nicely with examples here. Hope that helps   Bests AJ  On 2/16/06, Kashmira Patel (kupatel) <[EMAIL PROTECTED]> wrote: Hi all,    I am pretty new to using Postrgres, and have been looking at the messages in

Re: [SQL] Using EXPLAIN-ANALYZE

2006-02-16 Thread Andrew Sullivan
On Thu, Feb 16, 2006 at 12:07:10PM -0800, Kashmira Patel (kupatel) wrote: > Hi all, >I am pretty new to using Postrgres, and have been looking at the > messages in this forum for a while. I have noticed that the use of > EXPLAIN-ANALYZE is recommended quite a lot. I read the Postgres docs, > bu

[SQL] Using EXPLAIN-ANALYZE

2006-02-16 Thread Kashmira Patel \(kupatel\)
Hi all,    I am pretty new to using Postrgres, and have been looking at the messages in this forum for a while. I have noticed that the use of EXPLAIN-ANALYZE is recommended quite a lot. I read the Postgres docs, but am not quite sure I understand how this works. Is there some tutorial or a

Re: [SQL] group by complications

2006-02-16 Thread Mark Fenbers
Wow!  I didn't know you could have a (select ...) as a replacement for a 'from' table/query.  Your SQL worked as-is, except I had to add a 'limit 1' to the first subquery. Thanks!  I would have never figured that out on my own! Mark chester c young wrote: --- Mark Fenbers <[EMAIL PROTECTE

Re: [SQL] Using calculated columns as arguments in same SELECT

2006-02-16 Thread Michael Burke
On February 16, 2006 11:07 am, Michael Burke wrote: > Hello, > > I am looking to simplify this query (uses PostGIS, but I have encountered > this scenario with other chains of functions): > -- snip -- Immediately after sending this one, I realized I could do it with a sub-select: gtest=# SELECT

[SQL] Using calculated columns as arguments in same SELECT

2006-02-16 Thread Michael Burke
Hello, I am looking to simplify this query (uses PostGIS, but I have encountered this scenario with other chains of functions): gtest=# SELECT X( SetSRID( Transform( GeomFromText( 'POINT(142512 1020225)', 26910 ), 4326 ), -1) ) as xcoord, Y( SetSRID( Transfo

Re: [SQL] VIEWs and TEMP tables problem

2006-02-16 Thread Tom Lane
Markus Schaber <[EMAIL PROTECTED]> writes: > Antal Attila wrote: >> Is it BUG, or FEATURE? Has anybody got good ideas for solve this problem? > It is a feature. Right. Note that one possible answer is, after you make the temp table, to create a temp view referencing the temp table (and hiding th

Re: [SQL] How to force PostgreSQL using an index

2006-02-16 Thread Daniel Caune
> -Message d'origine- > De : Tom Lane [mailto:[EMAIL PROTECTED] > Envoyé : mercredi, février 15, 2006 17:47 > À : Daniel Caune > Cc : Andrew Sullivan; pgsql-sql@postgresql.org > Objet : Re: [SQL] How to force PostgreSQL using an index > > "Daniel Caune" <[EMAIL PROTECTED]> writes: > > SE

Re: [SQL] VIEWs and TEMP tables problem

2006-02-16 Thread Markus Schaber
Hi, Antal, Antal Attila wrote: > CREATE VIEW a_view AS SELECT * FROM a JOIN actual_code AC ON (a.code = > AC.code); Here, you bind the View to the permanent table. > CREATE TEMP TABLE actual_code AS SELECT 23::INT4 AS code; And here you create the temp table that will hide the permanent table.

Re: [SQL] VIEWs and TEMP tables problem

2006-02-16 Thread Richard Huxton
Antal Attila wrote: Hi! I found a problem with the views in PostgreSQL if I want to use temporary tables in it. See the next case! [snip] The problem is that the view use the original permanent table, but the 1) query use the temporary actual_code table. I read the temporally table definitio

[SQL] VIEWs and TEMP tables problem

2006-02-16 Thread Antal Attila
Hi! I found a problem with the views in PostgreSQL if I want to use temporary tables in it. See the next case! CREATE TABLE a(, code INT4,...); INSERT INTO a(...,code,...) VALUES (...,23,...); CREATE TABLE actual_code(code INT4); If I execute the next query, the result is empty. SELEC

Re: [SQL] to count no of columns in a table

2006-02-16 Thread Ragnar
On fim, 2006-02-16 at 14:43 +0530, AKHILESH GUPTA wrote: > i just want to know one thing that is there any function in PGSQL > which gives me the total number of columns in a table. > OR > just like we are using count(*), it gives us total number or rows in a > table, just like i want to know the t

Re: [SQL] to count no of columns in a table

2006-02-16 Thread A. Kretschmer
am 16.02.2006, um 14:43:43 +0530 mailte AKHILESH GUPTA folgendes: > hi all, > i just want to know one thing that is there any function in PGSQL which > gives me the total number of columns in a table. select count(column_name) from information_schema.columns where table_name='foo'; HTH, Andrea

Re: [SQL] to count no of columns in a table

2006-02-16 Thread Juris
Create view/storedproc on pg_class & pg_attribute tables 2006/2/16, AKHILESH GUPTA <[EMAIL PROTECTED]>: > hi all, > i just want to know one thing that is there any function in PGSQL which > gives me the total number of columns in a table. > OR > just like we are using count(*), it gives us to

[SQL] to count no of columns in a table

2006-02-16 Thread AKHILESH GUPTA
hi all, i just want to know one thing that is there any function in PGSQL which gives me the total number of columns in a table. OR just like we are using count(*), it gives us total number or rows in a table, just like i want to know the total number of columns present in the table plz help me