X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D822AD1D278 for ; Mon, 26 Jan 2004 19:03:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 84793-03 for ; Mon, 26 Jan 2004 15:03:07 -0400 (AST) Received: from unix.mail.Virginia.EDU (unix.mail.Virginia.EDU [128.143.2.28]) by svr1.postgresql.org (Postfix) with ESMTP id D8442D1D174 for ; Mon, 26 Jan 2004 15:02:51 -0400 (AST) Received: from smtp.mail.Virginia.EDU (smtp.mail.Virginia.EDU [128.143.22.52]) by unix.mail.Virginia.EDU (Postfix) with ESMTP id 6365BA927 for ; Mon, 26 Jan 2004 14:02:48 -0500 (EST) Received: from virginia.edu (d-137-133-128.bootp.Virginia.EDU [137.54.133.128]) by smtp.mail.Virginia.EDU (Postfix) with ESMTP id E9C102102F for ; Mon, 26 Jan 2004 14:02:47 -0500 (EST) Message-ID: <4015677D.3090808@virginia.edu> Date: Mon, 26 Jan 2004 14:16:13 -0500 From: Jodi Kanter User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Postgres Admin List Subject: [Fwd: binary tree query] Content-Type: multipart/alternative; boundary="------------040608030408080900050505" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/242 X-Sequence-Number: 12105 This is a multi-part message in MIME format. --------------040608030408080900050505 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit I have a biochemist telling me that this query below is a typical one for crawling through a taxonomic tree and that this is how I should represent some peptide information we have. Is there anyone on this list familiar with such data? I am weak in the science department but this query looks like it might not be the most efficient approach. I have not been able to run an explain analyze yet as the database structure and data are not in place yet. We are just in the planning stages right now. Any comments, suggestions, concerns, etc. would be much appreciated. Would an experienced DBA recommend a different approach? Can anyone offer some insight into the usefulness of INNER joins and the use of BETWEEN? I am concernec about performance as well since I expect this table to get large. SELECT count(*) FROM taxon_name INNER JOIN taxon AS tax_b USING(taxon_id) INNER JOIN taxon AS tax_v ON (tax_v.left_id BETWEEN tax_b.left_id AND tax_b.right_id ) INNER JOIN annot ON (tax_v.taxon_id = annot.taxon_id) INNER JOIN protein ON (protein.prot_id= annot.prot_id) WHERE annot.pref = 1 AND taxon_name.taxon_id=207245 ; Thanks, Jodi -- /_______________________________ //Jodi L Kanter BioInformatics Database Administrator University of Virginia (434) 924-2846 jkanter@virginia.edu / / / / / --------------040608030408080900050505 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit I have a biochemist telling me that this query below is a typical one for crawling through a taxonomic tree and that this is how I should represent some peptide information we have. Is there anyone on this list familiar with such data? I am weak in the science department but this query looks like it might not be the most efficient approach.
I have not been able to run an explain analyze yet as the database structure and data are not in place yet. We are just in the planning stages right now.

Any comments, suggestions, concerns, etc. would be much appreciated. Would an experienced DBA recommend a different approach? Can anyone offer some insight into the usefulness of INNER joins and the use of BETWEEN? I am concernec about performance as well since I expect this table to get large.

SELECT count(*)
  FROM taxon_name
       INNER JOIN taxon AS tax_b USING(taxon_id)
       INNER JOIN taxon AS tax_v ON (tax_v.left_id BETWEEN 
tax_b.left_id AND tax_b.right_id )
       INNER JOIN annot ON (tax_v.taxon_id = annot.taxon_id)
       INNER JOIN protein ON (protein.prot_id= annot.prot_id)
 WHERE annot.pref = 1
   AND taxon_name.taxon_id=207245
;


Thanks,
Jodi

--
________________________________

_______________________________
Jodi L Kanter
BioInformatics Database Administrator
University of Virginia
(434) 924-2846
jkanter@virginia.edu


 

 

 

--------------040608030408080900050505--