Re: [SQL] GiST, Not Using Index

2003-02-27 Thread Itai Zukerman
actual time=35.16..2231.98 rows=29 loops=1) Filter: (y ~>= '.*......'::sig) Total runtime: 2232.18 msec (3 rows) -- Itai Zukerman <http://www.math-hat.com/~zukerman/> ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

[SQL] btree_gist, gint4_union

2003-02-26 Thread Itai Zukerman
In contrib/btree_gist/ I see: CREATE FUNCTION gint4_union(bytea, internal) RETURNS int4 AS 'MODULE_PATHNAME' LANGUAGE 'C'; but gint4_union does this: INT4KEY *out = palloc(sizeof(INT4KEY)); [...] PG_RETURN_POINTER(out); Is the int4 return type declared ab

Re: [SQL] Foreign key problem

2001-06-25 Thread Itai Zukerman
TE UNIQUE INDEX IX_IdLabNr_KulturDetail ON ResKulturDetail(IdLabNr, IdIndex) ; I'm not sure why this restriction is necessary... -- Itai Zukerman <http://www.math-hat.com/~zukerman/> ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

[SQL] Inheritance: Performance & Indexes

2001-06-18 Thread Itai Zukerman
try to limit the delete to a1 wherever possible? Also, it looks like a1 doesn't inherit the primary key index. Is that intentional or a bug? Finally, is it possible to specify that x values be unique across both a *and* a1, without triggers? -- Itai Zukerman <http://www.math-hat.com/~

Re: [SQL] Persistent Connects (pg_pconnect)

2000-11-21 Thread Itai Zukerman
On Tue, 21 Nov 2000 12:34:19 +, Colleen Williams <[EMAIL PROTECTED]> wrote: > Each time one of us uses the CMS, a new > persistent connection process owned by postgres is started up. With 3 > people accessing the CMS sporadically, 32 persistent connections are > in existence and then Linux te

Re: [SQL] Variable-length Types

2000-10-15 Thread Itai Zukerman
> > 3. What sort of trouble am I going to get into trying to pull data from > > a custom type into an external interface (i.e. PHP4)? > > Good question --- the interface code might or might not have a sensible > default behavior for types it doesn't recognize. Why not explicitly convert to tex

[SQL] Variable-length Types

2000-10-15 Thread Itai Zukerman
I'm going from the documentation in the Programmer's Guide, chapter 4. I'd like to have the following type available in Postegres: typedef struct FullName { char *first; char *last; } FullName; According to the docs, it looks like I need to do something like: typedef struct FullName { in

[SQL] Operator Column

2000-10-13 Thread Itai Zukerman
I'd like to do something like this: create table value ( x int4 ) create index on value ( x ) create table filter ( op oid references pg_operator, endpoint int4 ) select value.x from value, filter where value.x filter.op filter.endpoint That is, I want the filter table to specify the oper

[SQL] Rules, Select, Union

2000-08-06 Thread Itai Zukerman
I'm doing this: CREATE TABLE data ( val int4 ); CREATE TABLE pos ( ) INHERITS ( data ); CREATE TABLE neg ( ) INHERITS ( data ); CREATE RULE data_to_pos AS ON INSERT TO data WHERE NEW.val > 0 DO INSTEAD INSERT INTO pos ( val ) VALUES ( NEW.val ); CREATE RULE data_to_neg AS ON

Re: [SQL] Time Aggregates

2000-08-02 Thread Itai Zukerman
> > SELECT symbol, date_trunc('minute', posted), > > min(price), max(price), avg(price) > > FROM trade > > GROUP BY symbol, date_trunc('minute', posted); Hmmm... I'm not sure how to go about doing this for, say, 5 minute intervals. Basically, I want a function: date_round( time

[SQL] Time Aggregates

2000-08-02 Thread Itai Zukerman
Hi, I'm currently doing this: SELECT symbol, date_trunc('minute', posted), min(price), max(price), avg(price) FROM trade GROUP BY symbol, date_trunc('minute', posted); to get a list of minute-averages of trade prices. I get the feeling that this is bad form, that I should be doi

Re: [SQL] Indices and time spans

2000-07-31 Thread Itai Zukerman
> You need to recast the clause as something like > > WHERE posted >= (CURRENT_TIMESTAMP - '5 minutes'::TIMESPAN) > > Then you still have the problem of persuading Postgres that it should > treat the right side of this as a constant and not something to > re-evaluate at each row. In 7.0 a

[SQL] Indices and time spans

2000-07-31 Thread Itai Zukerman
I have this: SELECT ... FROM trade, entry WHERE AGE( CURRENT_TIMESTAMP, posted ) <= '5 minutes'::TIMESPAN AND trade.entryId = entry.entryId That is, fetch all trades executed in the last 5 minutes. This query seems to run pretty slowly when trade is filled. Putting an

[SQL] Just 'sql'?

2000-07-29 Thread Itai Zukerman
Hi, I have this: CREATE FUNCTION queue_add() RETURNS OPAQUE AS 'BEGIN INSERT INTO queue ( count, price ) VALUES ( NEW.count, NEW.price ); RETURN NEW; END;' LANGUAGE 'plpgsql' ; I can't figure out how to do this with LANGUAGE 'sql'. Any ideas? Thanks, -itai

Re: [SQL] Conditional rule?

2000-07-28 Thread Itai Zukerman
> > CREATE RULE newsrule AS ON INSERT TO news > > WHERE new.publishtime NOTNULL DO > > INSERT INTO news_unpublished VALUES (new.id); > > The following happens: > rules=# insert into news (title, time) values('Hei', now()); > ERROR: referential integrity violation

[SQL] Automatic Deletes?

2000-07-27 Thread Itai Zukerman
Hi, I have: CREATE TABLE a ( id SERIAL, val INT4 ) ; I would like to create some rules to keep "a" free from rows where val == 0. Something like: CREATE RULE a_insert AS ON INSERT TO a WHERE NEW.val = 0 DO INSTEAD NOTHING ; CREATE RULE a_update AS ON UPDATE TO a WHERE NEW.val =

Re: [SQL] Conditional rule?

2000-07-27 Thread Itai Zukerman
> I.e. "On an insert to news, if new.publish is not null, insert the new > post's id into news_unpublished. How about: CREATE RULE newsrule AS ON INSERT TO news DO INSERT INTO news_unpublished SELECT NEW.id WHERE NEW.publishtime IS NOT NULL -itai

[SQL] Aggregates and Primary Keys

2000-07-27 Thread Itai Zukerman
Hi, I have this: create table a ( x int4 primary key, dat int4, count int4 ) ; create table b ( x int4 references a(x), count int4 ) ; insert into a values ( 1, 1, 10 ) ; insert into a values ( 2, 2, 20 ) ; insert into b values ( 1, 2 ) ; insert into b values ( 1, 3 ) ; insert int