[OGo-Developer] Locating Participants For New CalDAV Appointments

Helge Hess developer@opengroupware.org
Fri, 11 May 2007 15:24:16 +0200


On May 11, 2007, at 15:08, Adam Tauno Williams wrote:
> I'm curious if this is on purpose; maybe to support catching multiple
> recipients with the same e-mail address?

I think thats unlikely. Probably it doesn't cache results or its a  
plain bug.


> SELECT DISTINCT c1.company_id AS pkey   <--- GOT ME
> FROM company_value cv, person c1
> WHERE c1.is_person=1 AND (c1.is_account=1)
>   AND (c1.is_private=0 OR c1.is_private IS NULL)
>   AND ( lower(cv.value_string) = 'adam@morrison-ind.com'
>   AND lower(cv.attribute) = 'email1'
>   AND (c1.db_status <> 'archived')
>   AND c1.company_id = cv.company_id );

Oh well, this looks stupid anyways ;-) Should be something like

   SELECT C.company_id AS pkey FROM person C
   INNER JOIN company_value CV
   ON (CV.company_id = C.company_id
       AND CV.type = 'email1' AND CV.db_status<>'archived'
       AND LOWER(CV.value) = 'adam...'
       AND ...)
   WHERE ...
   LIMIT 1;

etc. Probably the SQL needs some refactoring. Though most likely  
PostgreSQL optimizes the stupidness away ;-)
Hm, the code probably should also fetch multiple records (all  
attendees) in one run (might be a another reason why you get multiple  
SQL queries).
However, writes are (usually) not that performance critical in OGo.

Greets,
   Helge
-- 
Helge Hess
http://www.helgehess.eu/