From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Neil Conway <nconway(at)klamath(dot)dyndns(dot)org> |
Cc: | PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: rules *very* slow? |
Date: | 2000-10-19 02:50:43 |
Message-ID: | 7198.971923843@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Neil Conway <nconway(at)klamath(dot)dyndns(dot)org> writes:
> I would expect the rule it cause a bit of overhead (maybe
> taking twice or three times as long as w/o the rule), but
> it's taking ~52x longer.
Ouch.
> I've tried creating an index on messages.poster, but it has
> no effect (performance is the same). I guesses that Postgres
> was ignoring the index so I disabled seqscan, but that had
> no effect.
An index on messages.poster wouldn't help here, AFAICS. The update
generated by the rule should be using an indexscan on the users.id
index (check this by doing an EXPLAIN on one of your insert commands).
> 1) Are rules really this slow?
Seems like they shouldn't be. Could you recompile with PROFILE=-pg
and get a gprof profile on the 3000-inserts test case?
> 2) Have I done something wrong? Is there a more efficient way to
> implement this?
Actually, I'd have gone for a trigger implemented by a plpgsql function,
so that you only pay the overhead of planning the UPDATE query once not
every time. But I don't think that should explain 52x, either.
As long as you've uncovered a problem, let's see if we can fix it before
you go off in a different direction.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-10-19 03:14:37 | Re: Is this a bug or a feature? |
Previous Message | Kevin O'Gorman | 2000-10-19 02:35:06 | Is this a bug or a feature? |