Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2010

    Unanswered: What is the best way to optimize this query

    Please tell me What is the best way to optimize this query

    select s.*,a.actid,,d.domid,d.domname,d.domno, tno,a.actname,p.descr
    as svcdescr from vwsubsmin s inner join packages p on s.svcno=p.pkgno inner join
    account a on a.actno=s.actno inner join ssgdom d on a.domno=d.domno inner join (select subsno from
    getexpiringsubs($1,cast($2 as integer),cast($3 as double precision), $4) as (subsno int,expirydt timestamp without time zone,balcpt double precision)) as e on s.subsno=e.subsno where s.status <=15 and d.domno=$5 order by d.domname,s.expirydt,a.actname

  2. #2
    Join Date
    Nov 2003
    Provided Answers: 23
    The first step would be to properly format the SQL so that it is readable.

    Then show us the execution plan of the query

    If you don't know what an execution plan is, I suggest you read the following:

    PostgreSQL: Documentation: Manuals: PostgreSQL 8.4: EXPLAIN
    Introduction to VACUUM, ANALYZE, EXPLAIN, and COUNT - PostgreSQL Wiki

    And please use [code] tags to display SQL queries when posting here.

Posting Permissions

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