Re: Question on COUNT performance - Mailing list pgsql-sql

From Lee Hachadoorian
Subject Re: Question on COUNT performance
Date
Msg-id 4C3E83E7.4010102@gmail.com
Whole thread Raw
In response to Re: Question on COUNT performance  (Anders Østergaard Jensen <aj@itersys.dk>)
List pgsql-sql
It appears that the acl functions use more SELECTs than necessary. For f_customer_acl(<span class="Apple-style-span"
style="font-family:arial,sans-serif; font-size: 13px; border-collapse: collapse;">uid integer, cid integer</span>), I
mightuse:<br /><br /> PERFORM 1 FROM customers JOIN users USING (org_id) WHERE customer_id = cid and user_id = uid;<br
/>RETURN FOUND;<br /><br /> This still requires one call to f_customer_acl() (and therefore one SELECT) for each row in
plan_events(since that's the way the calling function is written). If the goal is to count the number of plan_events a
specificuser has access rights to, I'm sure you can write a query that would accomplish that directly. It's beyond my
knowledgewhether it makes more sense to do this via these function calls.<br /><br /> --Lee<br /><br /><br /><pre
class="moz-signature"cols="72">-- 
 
Lee Hachadoorian
PhD Student, Geography
Program in Earth & Environmental Sciences
CUNY Graduate Center
</pre>

pgsql-sql by date:

Previous
From: Anders Østergaard Jensen
Date:
Subject: Re: Question on COUNT performance
Next
From: Thomas Kellerer
Date:
Subject: Re: subtract two dates to get the number of days