Re: [SQL] query speed joining tables

2003-01-13 Thread Tomasz Myrta
Christopher Smith wrote: >my mistakes, zips_max should be zips_300. >and >in my zip code table there are 120 million rows, example of the records >are > >origin destination >=== > >90210 90222 >90210 90234 >90210 96753 1.try to create inde

Re: [SQL] assigning values to array elements

2003-01-13 Thread Bruce Momjian
Tom Lane wrote: > J Greenbaum <[EMAIL PROTECTED]> writes: > > As you can see, I'm trying to assign a value to an array element, but it > > isn't working for some reason. > > plpgsql doesn't support that yet :-(. > > This needs to be fixed. I'm not sure why it doesn't have an entry in > TODO. Br

Re: [SQL] Postgresql Bug List?

2003-01-13 Thread Bruce Momjian
Go to the developer's site, and read the developer's FAQ, or see FAQ_DEV in the distribution. --- Wei Weng wrote: > Is there a bugzilla kind of thing for Postgresql? > > I would like to help out on the development, but have

Re: [SQL] insert rule doesn't see id field

2003-01-13 Thread Tom Lane
Ron Peterson <[EMAIL PROTECTED]> writes: > I can find out this info > for the relation pulling the trigger easy enought, but how would I go > about getting this info when all I have is the table/field name? I > could create and execute a SQL query something like the following, but > is that really

Re: [SQL] insert rule doesn't see id field

2003-01-13 Thread Ron Peterson
On Tue, Jan 07, 2003 at 11:01:08AM -0500, Tom Lane wrote: > Ron Peterson <[EMAIL PROTECTED]> writes: > > CREATE RULE person_insert AS > > ON INSERT TO person > > DO > > INSERT INTO person_log ( name_last, name_first, mod_type, person_id ) > > VALUES ( new.name_last, new.name_first, 'I', new

Re: [SQL] query speed joining tables

2003-01-13 Thread Christopher Smith
my mistakes, zips_max should be zips_300.  Tomasz Myrta <[EMAIL PROTECTED]> wrote: Christopher Smith wrote:> I have 4 tables that I need to query... 3 of the tables are links by the> field userid.>> below are table sql fragments. as well as the query. The subquery> causes very high>> CPU usages. It

Re: [SQL] query speed joining tables

2003-01-13 Thread Tomasz Myrta
Christopher Smith wrote: I have 4 tables that I need to query... 3 of the tables are links by the field userid. below are table sql fragments. as well as the query. The subquery causes very high CPU usages. It typically returns ~3000 matches. Is there another way to rewrite this? SELECT user

Re: [SQL] query speed joining tables

2003-01-13 Thread Christopher Smith
I understand cachable functions but your proposed application is a little unclear. is it possible to see an example? thanks in advance.  Josh Berkus <[EMAIL PROTECTED]> wrote: Chris,Here are probably your two main query problems:> strpos(user_match_details.ethnicity,'Asian') !=0 ANDIt is impossible

Re: [SQL] query speed joining tables

2003-01-13 Thread Josh Berkus
Chris, Here are probably your two main query problems: > strpos(user_match_details.ethnicity,'Asian') !=0 AND It is impossible for Postgres to use an index for the above as it is written. I would suggest one of two improvements; 1) Modify the schema so that multiple ethnicity details are kept

[SQL] query speed joining tables

2003-01-13 Thread Christopher Smith
I have 4 tables that I need to query... 3 of the tables are links by the field userid. below are table sql fragments. as well as the query.  The subquery causes very high CPU usages.  It typically returns ~3000 matches. Is there another way to rewrite this?  SELECT user_login.userid FROM user_log

Re: [SQL] assigning values to array elements

2003-01-13 Thread J Greenbaum
Darn...guess I gotta do it in perl then. Thx for your help. On Mon, 13 Jan 2003, Tom Lane wrote: > J Greenbaum <[EMAIL PROTECTED]> writes: > > As you can see, I'm trying to assign a value to an array element, but it > > isn't working for some reason. > > plpgsql doesn't support that yet :-(. >

Re: [SQL] assigning values to array elements

2003-01-13 Thread Tom Lane
J Greenbaum <[EMAIL PROTECTED]> writes: > As you can see, I'm trying to assign a value to an array element, but it > isn't working for some reason. plpgsql doesn't support that yet :-(. This needs to be fixed. I'm not sure why it doesn't have an entry in TODO. Bruce, would you add something lik

[SQL] assigning values to array elements

2003-01-13 Thread J Greenbaum
Hello, I'm fairly new to postgres and I'm trying to write a PL/pgsql function and keep getting an error message. Here is the line that is giving me trouble: norm[i] := (NEW.area[i]/(A_slope * (i+18) + A_int)+NEW.area[i]/(C_slope * (i+18) + C_int))/2; The error message that I receive is: WARNING

Re: [SQL] PgSQL 7.3: /opt/pgsql/bin/postgres: Execute permission denied.

2003-01-13 Thread Chris Travers
Try running the initdb program first. Best Wishes, Chris Travers - Original Message - From: "Zengfa Gao" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, January 08, 2003 9:43 AM Subject: [SQL] PgSQL 7.3: /opt/pgsql/bin/postgres: Execute permission denied. > Hi, > > I downlo

Re: [SQL] Crosstab-style query in pure SQL

2003-01-13 Thread dev
> Richard, > >> I have a table containing milestones achieved for projects, marked as >> being in particular quarters. >> >> CREATE TABLE milestones ( >> proj_id int4, >> sortorder SERIAL, >> qtr int4, >> description varchar(200) >> ); >> >> Now I need the milestone de

Re: [SQL] to_date confusion

2003-01-13 Thread Stephan Szabo
On Mon, 13 Jan 2003, Josh Berkus wrote: > Richard, > > > I'm confused. How do I get the integer 10102 to come in as the date > > 2002-01-01? > > Hmmm ... isn't this an old post, repeating? Yep, my guess is that he sent it, wasn't on the list so it went for approval, he joined and resent, and we

Re: [SQL] Returning row or rows from function?

2003-01-13 Thread Tomasz Myrta
David Durst wrote: I want to create a function that will return a row or rows of a table is this possible? If so can someone replay with a complete example? I propose you reading a document of Stephan Szabo about functions returning sets. You need postgresql 7.3 to do this. http://techdocs.po

Re: [SQL] Returning row or rows from function?

2003-01-13 Thread Stephan Szabo
On Wed, 8 Jan 2003, David Durst wrote: > I want to create a function that will return > a row or rows of a table is this possible? It is in 7.3. > If so can someone replay with a complete example? You can find some examples in: http://techdocs.postgresql.org/guides/SetReturningFunctions

Re: [SQL] to_date confusion

2003-01-13 Thread Josh Berkus
Richard, > I'm confused. How do I get the integer 10102 to come in as the date > 2002-01-01? Hmmm ... isn't this an old post, repeating? -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 1: subscribe and unsu

Re: [SQL] Inherancing

2003-01-13 Thread Daniel Schuchardt
You have to insert in th centers-table. Because it is inherited from cities, the record is automatically in cities. Search for SELECT * FROM ONLY in the docs too. > create table cities (id int, name varchar, primary key(id) ); > create table centers (state varchar(2)) inherits (cities); > > ant th

[SQL] to_date confusion

2003-01-13 Thread Richard Rowell
I'm confused. How do I get the integer 10102 to come in as the date 2002-01-01? cmi=> select to_date('010102','MMDDYY'); to_date 2002-01-01 (1 row) cmi=> select to_char(10102,'00'); to_char - 010102 (1 row) cmi=> select to_date(to_char(10102,'00'),'MMDDYY'

[SQL] Returning row or rows from function?

2003-01-13 Thread David Durst
I want to create a function that will return a row or rows of a table is this possible? If so can someone replay with a complete example? ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unre

[SQL] Postgresql Bug List?

2003-01-13 Thread Wei Weng
Is there a bugzilla kind of thing for Postgresql? I would like to help out on the development, but have no idea where to start... Thanks Wei ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send

[SQL] PgSQL 7.3: /opt/pgsql/bin/postgres: Execute permission denied.

2003-01-13 Thread Zengfa Gao
Hi, I download PgSQL source, compiled it, then try to start pgsql, I got: # su postgres -c '/opt/pgsql/bin/initdb --pgdata=/var/opt/pgsql/data' The program '/opt/pgsql/bin/postgres' needed by initdb does not belong to PostgreSQL version 7.3, or there may be a configuration problem. This wa

Re: [SQL] Crosstab-style query in pure SQL

2003-01-13 Thread Josh Berkus
Richard, > I have a table containing milestones achieved for projects, marked as > being in particular quarters. > > CREATE TABLE milestones ( > proj_id int4, > sortorder SERIAL, > qtr int4, > description varchar(200) > ); > > Now I need the milestone descriptions o

Re: [SQL] Unique indexes not unique?

2003-01-13 Thread Tom Lane
Stephan Szabo <[EMAIL PROTECTED]> writes: > In his actual query (he sent me explain results which include the query) > he uses ::bigint on both constants. Okay, scratch that theory. > Limit (cost=22669.68..22669.68 rows=95 width=372) > -> Sort (cost=22669.68..22669.68 rows=96 width=372) >

Re: [SQL] Unique indexes not unique?

2003-01-13 Thread Stephan Szabo
On Mon, 13 Jan 2003, Tom Lane wrote: > Stephan Szabo <[EMAIL PROTECTED]> writes: > > On Mon, 13 Jan 2003, [iso-8859-1] Jimmy Mäkelä wrote: > > On my dev (7.4devel) box I see it using the composite index three times, > > but you haven't given explain output for the two queries or any statistics >

Re: [SQL] Unique indexes not unique?

2003-01-13 Thread Tom Lane
Stephan Szabo <[EMAIL PROTECTED]> writes: > On Mon, 13 Jan 2003, [iso-8859-1] Jimmy Mäkelä wrote: >> And another completely unrelated question... I have got a table with a composite >> index on A andBb and an index on A >> which I query with something like this: >> >> SELECT * FROM "table" >> WHER

[SQL] Crosstab-style query in pure SQL

2003-01-13 Thread dev
TIA all I have a table containing milestones achieved for projects, marked as being in particular quarters. CREATE TABLE milestones ( proj_id int4, sortorder SERIAL, qtr int4, description varchar(200) ); Now I need the milestone descriptions output across the page l

Re: [SQL] Unique indexes not unique?

2003-01-13 Thread dev
> Jimmy Mäkelä wrote: > >> I found that Postgres isn't behaving like I thought when using a >> unique index in >> combination with NULL-values... >> Is this a bug or specified in the SQL-standard? If its a bug, is it >> fixed in a >> recent version? We are using 7.2.3 >> intranet=# insert into "fo

Re: [SQL] Unique indexes not unique?

2003-01-13 Thread Stephan Szabo
On Mon, 13 Jan 2003, [iso-8859-1] Jimmy Mäkelä wrote: > I found that Postgres isn't behaving like I thought when using a unique index in > combination with NULL-values... > Is this a bug or specified in the SQL-standard? If its a bug, is it fixed in a > recent version? We are using 7.2.3 AFAIK th

Re: [SQL] Unique indexes not unique?

2003-01-13 Thread Jimmy Mäkelä
From: Tomasz Myrta [mailto:[EMAIL PROTECTED]] > I'm not sure unique index works properly for null values. I can't > explain, why. Maybe it comes from SQL standard - null i a > special value Yeah, I thought about that too, but I think that behaviour is really bad and would consider it a bug. The

Re: [SQL] Unique indexes not unique?

2003-01-13 Thread Tomasz Myrta
Jimmy Mäkelä wrote: I found that Postgres isn't behaving like I thought when using a unique index in combination with NULL-values... Is this a bug or specified in the SQL-standard? If its a bug, is it fixed in a recent version? We are using 7.2.3 This is the results I got: intranet=# create t

[SQL] Unique indexes not unique?

2003-01-13 Thread Jimmy Mäkelä
I found that Postgres isn't behaving like I thought when using a unique index in combination with NULL-values... Is this a bug or specified in the SQL-standard? If its a bug, is it fixed in a recent version? We are using 7.2.3 This is the results I got: intranet=# create table foo (a varchar(10),