Re: [SQL] Does VACUUM reorder tables on clustered indices

2005-12-21 Thread Bruce Momjian
Chris Browne wrote: > [EMAIL PROTECTED] ("Jim C. Nasby") writes: > > On Wed, Dec 21, 2005 at 12:34:12AM +0100, [EMAIL PROTECTED] wrote: > >> Hi, > >> > >> Utilize CLUSTER; (after vacuum) to reorder the data. > > > > Why would you vacuum when cluster is just going to wipe out the dead > > tuples an

Re: [SQL] Help on a complex query (avg data for day of the week)

2005-12-21 Thread Matthew Smith
Michael, Thanks heaps for that! Cheers, Matt Smith On Thu, 22 Dec 2005 01:37 pm, Michael Fuhr wrote: > On Thu, Dec 22, 2005 at 11:59:24AM +1100, Matthew Smith wrote: > > Sadly I am using 7.3, it seems that generate_series() is 8.0 and later. > > Yes, but it's easily written in PL/pgSQL for earl

[SQL] lo function changed in PostgreSQL 8.1.1 (ask again)

2005-12-21 Thread Premsun Choltanwanich
From contrib/lo I found that it has something  difference between old and new version of PostgreSQL.  And I'm sure that I already tick on Large Object (lo) option when I install.   How can I manage on difference function?       :::New Version::: DOMAIN lo AS pg_catalog.oid;   FUNCTION lo_oid(lo)

Re: [SQL] Help on a complex query (avg data for day of the week)

2005-12-21 Thread Michael Fuhr
On Thu, Dec 22, 2005 at 11:59:24AM +1100, Matthew Smith wrote: > Sadly I am using 7.3, it seems that generate_series() is 8.0 and later. Yes, but it's easily written in PL/pgSQL for earlier versions. Example: CREATE FUNCTION generate_series(integer, integer) RETURNS SETOF integer AS ' DECLARE

Re: [SQL] Help on a complex query (avg data for day of the week)

2005-12-21 Thread Matthew Smith
Richard (and list), Thanks for the help! More below: On Wed, 21 Dec 2005 09:04 pm, Richard Huxton wrote: > Matthew Smith wrote: > > I want to form a query that returns the average total usage for each day > > of the week, eg: > > [snip] > > > To get this info, I am using the following query: > >

Re: [SQL] Does VACUUM reorder tables on clustered indices

2005-12-21 Thread Chris Browne
[EMAIL PROTECTED] ("Jim C. Nasby") writes: > On Wed, Dec 21, 2005 at 12:34:12AM +0100, [EMAIL PROTECTED] wrote: >> Hi, >> >> Utilize CLUSTER; (after vacuum) to reorder the data. > > Why would you vacuum when cluster is just going to wipe out the dead > tuples anyway? There is one reason to VACUUM

Re: [SQL] Problem obtaining MAX values FROM TABLE

2005-12-21 Thread Michael Fuhr
On Fri, Dec 16, 2005 at 03:42:34PM -, Michael Farewell wrote: > I need to write a query which returns each company together with the > highest product_count and its associated product type so the result should > look like this: There are a few ways to do this, a couple of which were mentioned

Re: [SQL] Help on a complex query (avg data for day of the week)

2005-12-21 Thread Richard Huxton
Matthew Smith wrote: I want to form a query that returns the average total usage for each day of the week, eg: [snip] To get this info, I am using the following query: select dow as day, sum(sum_data)/count(dow) as avg_usage from (select extract('dow' from date_trunc('day', time)) as dow, sum

Re: [SQL] Commiting after certain no of rows have been deleted

2005-12-21 Thread Richard Huxton
Smita Mahadik wrote: Hi, In my application I m deleteing large no of rows from table based on certain condition. This takes lot of time and if sometimes my application fails it starts all over again...since the coomit is done at the end of transactions. Is there a way i can do commit when certai

Re: [SQL] Help me do a LOOP

2005-12-21 Thread Richard Huxton
Calin Meze wrote: I need to test each record of a cursor for some requirements, something like this [snip] -- the problem is that I do not know how to make the while loop execute until the last record "WHILE (still in the cursor)"... So I need something like Can anyone help me with this? It