From: | "Stewart Ben (RBAU/EQS4) *" <Ben(dot)Stewart(at)au(dot)bosch(dot)com> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: automatic update or insert |
Date: | 2005-10-25 02:43:00 |
Message-ID: | E253BDD7F008244585AEE87AF8F0224F116C7B15@cl-mail01.au.bosch.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
> Currently i have implemented this as a stored procedure in the plpgsql
> language. This means that in my stored procedure i first do a
> select to
> find out if the row exists or not, then i do a insert or update
> depending if the row existed.
>
> Unfortunately, stored procedures seems awfully slow. And i need the
> application to go faster.
Do you have indexes on the columns being looked up? Make sure you create
the index then ANALYZE.
> One solution could be to implement the stored procedure in my program
> instead. I think that this will be atleast 50% faster than my stored
> procedure, so that would be ok.
>
> However, this has made me thinking. Couldn't this be done directly in
> SQL?
You could probably implement this as a trigger on the table for INSERT.
Have a squiz through the documentation on triggers.
Best regards,
Ben Stewart
--
Robert Bosch (Australia) Pty. Ltd.
Engineering Quality Services, Student Software Engineer (RBAU/EQS4)
Locked Bag 66 - Clayton South, VIC 3169 - AUSTRALIA
mailto:ben(dot)stewart(at)au(dot)bosch(dot)com
http://www.bosch.com.au/
From | Date | Subject | |
---|---|---|---|
Next Message | Stewart Ben (RBAU/EQS4) * | 2005-10-25 02:45:43 | Re: how to create rule as on delete |
Previous Message | Bruno Wolff III | 2005-10-24 17:02:00 | Re: query tables based on a query |