Re: [SQL] Query performance problem

2005-03-17 Thread Ragnar Hafstað
On Fri, 2005-03-18 at 10:49 +0530, Kenneth Gonsalves wrote: > On Thursday 17 Mar 2005 7:35 pm, Richard Huxton wrote: > > > Not necessarily. NOT NULL here helps to ensure you can add values > > together without the risk of a null result. There are plenty of > > "amount" columns that should be not-n

Re: [SQL] Query performance problem

2005-03-17 Thread Kenneth Gonsalves
On Thursday 17 Mar 2005 7:35 pm, Richard Huxton wrote: > Not necessarily. NOT NULL here helps to ensure you can add values > together without the risk of a null result. There are plenty of > "amount" columns that should be not-null (total spent, total > ordered etc). that makes sense - but is it

Re: [SQL] Process priority.

2005-03-17 Thread Theo Galanakis
Title: RE: [SQL] Process priority. It depends what the intended purpose if for. In our scenario, there are a number of ad-hoc export tasks running during the day that are quite cpu intensive. There is a noticeably slow response time when exports are being run. By lowering the priority of th

Re: [SQL] Process priority.

2005-03-17 Thread Tom Lane
Theo Galanakis <[EMAIL PROTECTED]> writes: > I wrote a C program that can be called through postgres via stored > procedures. It allows you to change the current postmaster process priority. You are aware that that's widely considered either useless or counterproductive? Renice-ing one back

[SQL] Process priority.

2005-03-17 Thread Theo Galanakis
Title: Process priority. Hi,     I wrote a C program that can be called through postgres via stored procedures. It allows you to change the current postmaster process priority.     Essentially it's intended purpose would be to allow a highly resource intensive postmaster process to ru

Re: [SQL] Consecutive row count query

2005-03-17 Thread Andrew Hammond
You could hack it using a custom aggregate. NB: you'll want to reset the categorizer_seq every now and then. And this isn't safe for concurrent queries. You could make it safe for concurrent queries by using a complex type for STYPE, but I didn't bother. I also haven't debugged this, but I thi

Re: [SQL] Consecutive row count query

2005-03-17 Thread Greg Stark
Leon Stringer <[EMAIL PROTECTED]> writes: > Hi, > > I wondered if anyone could answer the following question: > > If I have a table such as the one below: > > col1 col_order > --- > Apple 1 > Apple 2 > Orange 3 > Banana 4 > Apple 5 > > Is there a way I can get the following result

Re: [SQL] Consecutive row count query

2005-03-17 Thread Jaime Casanova
On Thu, 17 Mar 2005 20:21:24 +, Leon Stringer <[EMAIL PROTECTED]> wrote: > Hi, > > I wondered if anyone could answer the following question: > > If I have a table such as the one below: > > col1 col_order > --- > Apple 1 > Apple 2 > Orange 3 > Banana 4 > Apple 5 > > Is there a

Re: [SQL] Consecutive row count query

2005-03-17 Thread Bruno Wolff III
On Thu, Mar 17, 2005 at 20:21:24 +, Leon Stringer <[EMAIL PROTECTED]> wrote: > Hi, > > I wondered if anyone could answer the following question: > > If I have a table such as the one below: > > col1 col_order > --- > Apple 1 > Apple 2 > Orange 3 > Banana 4 > Apple 5 > > Is th

[SQL] Consecutive row count query

2005-03-17 Thread Leon Stringer
Hi, I wondered if anyone could answer the following question: If I have a table such as the one below: col1 col_order --- Apple 1 Apple 2 Orange 3 Banana 4 Apple 5 Is there a way I can get the following results: Apple 2 Orange 1 Banana 1 Apple 1 i.e. Each row is printed ordered

Re: [SQL] lower and unicode

2005-03-17 Thread Peter Eisentraut
pginfo wrote: > I am uusing pg 8.0.1 on FreeBSD 5.3 but I am ready t use the version > taht supports correct unicode. FreeBSD doesn't support Unicode, so you need to use something else. -- Peter Eisentraut http://developer.postgresql.org/~petere/ ---(end of broadcast)---

Re: [SQL] update with subselect (long)

2005-03-17 Thread Leif B. Kristensen
On Thursday 17 March 2005 15:01, Stephan Szabo wrote: > The above needs some work. The below should be acceptable to the > system. > > update name_parts set name_part_type=5 from (select name_id from > name_parts where name_part_type=6) as gpt_type where > name_parts.name_id=gpt_type.name_id and

Re: [SQL] Query performance problem

2005-03-17 Thread Richard Huxton
Kenneth Gonsalves wrote: On Thursday 17 Mar 2005 1:50 pm, Phil Daintree wrote: CREATE TABLE chartdetails ( accountcode integer DEFAULT 0 NOT NULL, period integer DEFAULT 0 NOT NULL, budget double precision DEFAULT (0)::double precision NOT NULL, actual double precision DEFAULT (0)::dou

Re: [SQL] update with subselect (long)

2005-03-17 Thread Stephan Szabo
On Thu, 17 Mar 2005, Leif B. Kristensen wrote: > CREATE TABLE name_part_types ( -- a key/label pair > name_part_type_id INTEGER PRIMARY KEY, > name_part_type VARCHAR(50) > ); > > > CREATE TABLE names ( -- one person can have multiple names > name_id INTEGER PRIMARY KEY, > person_i

Re: [SQL] Query performance problem

2005-03-17 Thread PFC
although may be not relevant to your question, as i have noticed this before with mysql 'sql', what is the point of having a NOT NULL field that defaults to 0? the whole idea of a NOT NULL field is to have the value filled in compulsorily and having a default of 0 or '' defeats the purpose Well i

Re: [SQL] update with subselect (long)

2005-03-17 Thread Leif B. Kristensen
On Thursday 17 March 2005 14:07, Leif B. Kristensen wrote: > slekta=> update name_parts set name_part_type=6 where > name_part_type=3; This message was sent a little prematurely while I was editing a similar posting to comp.databases. The cited line is erroneous and should read: > slekta=> upda

[SQL] update with subselect (long)

2005-03-17 Thread Leif B. Kristensen
Hello all, I'm working with a genealogy database where I try to implement a somewhat unconventional model for names. The purpose is to allow different naming styles, especially the old Norwegian naming style with Given name/Patronym/Toponym instead of the Given/Patronym style that appears as Go

Re: [SQL] Query performance problem

2005-03-17 Thread Kenneth Gonsalves
On Thursday 17 Mar 2005 1:50 pm, Phil Daintree wrote: > CREATE TABLE chartdetails ( > accountcode integer DEFAULT 0 NOT NULL, > period integer DEFAULT 0 NOT NULL, > budget double precision DEFAULT (0)::double precision NOT NULL, > actual double precision DEFAULT (0)::double precisi

Re: [SQL] query

2005-03-17 Thread Richard Huxton
Terry Fielder wrote: now() returns a timestamp. Cast it to a date and then you can subtract days. e.g. select now()::date -1 Or CURRENT_DATE - 1 *In oracle we write sysdate-1* *For example,we write a query (select * from table1 where created_date>=sysdate-1).Whats its equivalent in postgre?* --

Re: [SQL] query

2005-03-17 Thread Terry Fielder
now() returns a timestamp. Cast it to a date and then you can subtract days. e.g. select now()::date -1 Terry Chandan_Kumaraiah wrote:   Hi,   In oracle we write sysdate-1 For example,we write a query (select * from table1 where created_date>=sysdate-1).Whats its equi

Re: [SQL] Query performance problem

2005-03-17 Thread PFC
Can anyone tell me why does the following code chokes ... literally - this works almost invisbly under mysql - pg takes more than an hour even on a very small 30 record database. - You should really use 8.0 - How much time toes it takes without the INSERT/UPDATES ? - Please

[SQL] query

2005-03-17 Thread Chandan_Kumaraiah
  Hi,   In oracle we write sysdate-1 For example,we write a query (select * from table1 where created_date>=sysdate-1).Whats its equivalent in postgre?   Chandan  

Re: [SQL] How to force subquery scan?

2005-03-17 Thread Tambet Matiisen
> -Original Message- > From: Tom Lane [mailto:[EMAIL PROTECTED] > Sent: Wednesday, March 16, 2005 5:42 PM > To: Tambet Matiisen > Cc: [EMAIL PROTECTED]; pgsql-sql@postgresql.org > Subject: Re: [SQL] How to force subquery scan? > > > "Tambet Matiisen" <[EMAIL PROTECTED]> writes: > > It

[SQL] Query performance problem

2005-03-17 Thread Phil Daintree
Dear psqlers, I need your help! I administer/develop an open source PHP accounting software project (webERP) that was originally mysql only. Since Christmas I and another member of the team lower cased all the sql and changed some elements of the SQL to allow it to use postgres as well. All app