Results 1 to 2 of 2

Thread: Query

  1. #1
    Join Date
    Dec 1969

    Default Query

    Hi,<BR><BR>I have this query in the program which uses some tables and joins. The query works fine but it is a lot slower. Is there a way I can make it faster.<BR><BR>strSQL = "select distinct x.prod-id,y.description__1,y.description__2,x.prod-rel,x.rel-status,x.rel-reason,a.description,x.afo"<BR>strsql = strsql & " from product.p-product x left outer join product.p-available z on (x.prod-id=z.prod-id) and (x.prod-rel=z.prod-rel) "<BR>strsql = strsql & " inner join product.p-attribute y on (x.prod-id=y.prod-id) left outer join product.t-media-set a on (z.media-set=a.code)"<BR>strsql = strsql & " where x.active = True and x.prod-id like &#039;%"& p_pid &"%&#039; and "<BR>strsql = strsql & " x.prod-rel like &#039;"& p_rel &"%&#039; and (y.description__1 like &#039;%"& p_tt &"%&#039; or y.description__2 like &#039;%"& p_tt &"%&#039;) "<BR>if p_d1 &#060;&#062;"" and p_d2 &#060;&#062;"" then<BR> strsql = strsql & " and x.afo &#062; "& p_d1 &" and x.afo &#060; "& p_d2 &" " <BR>end if <BR><BR>I still have to add one or two tables which will make it more slow.<BR><BR>Thanks,<BR>Archna

  2. #2
    rwadkins@tsccg.com Guest

    Default RE: Query

    I have found that when complex queries with diverse join types seriously slow down a query, it&#039;s better to rewrite the query into several different queries, creating temporary tables and modifying the data along the way. As your query gets more complex, this method becomes faster. However, this will slow down simpler queries, so you need to do some testing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts