Re: [SQL] Non Matching Records in Two Tables

2006-02-14 Thread Bryce Nesbitt
Ken Hill wrote: >> also (hate to be obvious) have you analyzed lately? >> I'd say that's fair game, not obvious. Vacuum/Analyze is ar so aparent to a person moving to Postgres from other DB's. ---(end of broadcast)--- TIP 4: Have you searched

Re: [SQL] Non Matching Records in Two Tables

2006-02-14 Thread Ken Hill
On Tue, 2006-02-14 at 13:24 -0800, Ken Hill wrote: On Tue, 2006-02-14 at 13:08 -0800, chester c young wrote: > Here is my query SQL: > > SELECT key100 FROM ncccr10 > WHERE ncccr10.key100 NOT IN (SELECT key100 FROM ncccr9); > > It is is running after 30 minutes. Here is the query p

Re: [SQL] create table and data types

2006-02-14 Thread Bath, David
On Tue, 2006-02-14 at 22:12 +0100, Maciej Piekielniak wrote: (snipped) >Is anybody know how create field in a new table with data type accuiring >from a field in other table? >For example: > create table new_table ( name other_table.name%TYPE); On Wed, 15 Feb 2006 09:42, Ken Hill wrote: (snipped)

Re: [SQL] create table and data types

2006-02-14 Thread Ken Hill
On Tue, 2006-02-14 at 23:03 +0100, Maciej Piekielniak wrote: Hello Ken, Tuesday, February 14, 2006, 10:30:34 PM, you wrote: KH> On Tue, 2006-02-14 at 22:12 +0100, Maciej Piekielniak wrote: >> Hello pgsql-sql, >> >> Is anybody know how create field in a new table with data type accuiring

Re: [SQL] create table and data types

2006-02-14 Thread Tom Lane
Maciej Piekielniak <[EMAIL PROTECTED]> writes: > Is anybody know how create field in a new table with data type accuiring > from a field in other table? Sorry, the %TYPE syntax only works in function declarations at the moment. It could possibly be made to work in table declarations --- there

Re: [SQL] create table and data types

2006-02-14 Thread Maciej Piekielniak
Hello Ken, Tuesday, February 14, 2006, 10:30:34 PM, you wrote: KH> On Tue, 2006-02-14 at 22:12 +0100, Maciej Piekielniak wrote: >> Hello pgsql-sql, >> >> Is anybody know how create field in a new table with data type accuiring >> from a field in other table? >> For example: >> >> create ta

Re: [SQL] create table and data types

2006-02-14 Thread Ken Hill
On Tue, 2006-02-14 at 22:12 +0100, Maciej Piekielniak wrote: Hello pgsql-sql, Is anybody know how create field in a new table with data type accuiring from a field in other table? For example: create table new_table ( name other_table.name%TYPE ); Have you tried inheritance from o

Re: [SQL] Non Matching Records in Two Tables

2006-02-14 Thread Ken Hill
On Tue, 2006-02-14 at 16:07 -0500, Tom Lane wrote: Ken Hill <[EMAIL PROTECTED]> writes: > Seq Scan on ncccr10 (cost=0.00..20417160510.08 rows=305782 width=104) >Filter: (NOT (subplan)) >SubPlan > -> Seq Scan on ncccr9 (cost=0.00..65533.71 rows=494471 width=104) > (4 rows) >

Re: [SQL] Non Matching Records in Two Tables

2006-02-14 Thread Ken Hill
On Tue, 2006-02-14 at 13:08 -0800, chester c young wrote: > Here is my query SQL: > > SELECT key100 FROM ncccr10 > WHERE ncccr10.key100 NOT IN (SELECT key100 FROM ncccr9); > > It is is running after 30 minutes. Here is the query plan: > I would try an outer join: select a.key100 from nccc

[SQL] create table and data types

2006-02-14 Thread Maciej Piekielniak
Hello pgsql-sql, Is anybody know how create field in a new table with data type accuiring from a field in other table? For example: create table new_table ( name other_table.name%TYPE ); -- Best regards, Maciej mailto:[EMAIL PROTECTED] ---

Re: [SQL] Non Matching Records in Two Tables

2006-02-14 Thread chester c young
> Here is my query SQL: > > SELECT key100 FROM ncccr10 > WHERE ncccr10.key100 NOT IN (SELECT key100 FROM ncccr9); > > It is is running after 30 minutes. Here is the query plan: > I would try an outer join: select a.key100 from ncccr10 a left join ncccr9 b on( key100 ) where b.key100 is null;

Re: [SQL] Non Matching Records in Two Tables

2006-02-14 Thread Tom Lane
Ken Hill <[EMAIL PROTECTED]> writes: > Seq Scan on ncccr10 (cost=0.00..20417160510.08 rows=305782 width=104) >Filter: (NOT (subplan)) >SubPlan > -> Seq Scan on ncccr9 (cost=0.00..65533.71 rows=494471 width=104) > (4 rows) > Any ideas why it is so slow? "NOT (subplan)" is horrendo

Re: [SQL] Non Matching Records in Two Tables

2006-02-14 Thread Ken Hill
On Wed, 2006-02-08 at 22:31 +0100, Markus Schaber wrote: Hi, Ken, Ken Hill schrieb: > I need some help with a bit of SQL. I have two tables. I want to find > records in one table that don't match records in another table based on > a common column in the two tables. Both tables have a column

Re: [SQL] Slow update SQL

2006-02-14 Thread Markus Schaber
Hi, Ken, Ken Hill wrote: > Removing the indexes, running the update SQL, and then adding back the > indexes worked much faster. Thank you for you help. It might be a good idea to run VACUUM FULL between updating and reindexing. If you want to CLUSTER on an index, it will be best to create this

Re: [SQL] Slow update SQL

2006-02-14 Thread Ken Hill
On Mon, 2006-02-13 at 22:17 -0700, Michael Fuhr wrote: [Please copy the mailing list on replies.] On Mon, Feb 13, 2006 at 06:48:06PM -0800, Ken Hill wrote: > On Mon, 2006-02-13 at 19:14 -0700, Michael Fuhr wrote: > > How many rows does the condition match? > > csalgorithm=# SELECT count(*) F

Re: [SQL] Trigger/Sequence headache

2006-02-14 Thread Markus Schaber
Hi, Stephen, Foster, Stephen wrote: > That's what I thought was going to be the answer. I was just hoping I > was making a mistake somehow. It's no big deal but I like things > organized and hate giant holes. > > Ok, one more thing for one of the batch jobs. No problem I have a > cleanup routi