Strange variable behaviour when using it in limit clause in plpgsql stored procedure

From: "Sergey Moroz" <smo(at)mgcp(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Strange variable behaviour when using it in limit clause in plpgsql stored procedure
Date: 2007-11-08 11:50:49
Message-ID: 9d39d250711080350iafac9b0j31a059f11d6af88@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I tested performance of my query with limit clause inside plpgsql procedure.
2 slightly different situations:

1. Sql with limit clause and literal variable (for example 'select field1
from table1 limit 100')
2. The same sql with limit clause and pgplsql variable (for example 'select
field1 from table1 limit vilimit'). vilimit defined in declare section.

At first I compared execution plans. they were absolutely equal!
But in fact first procedure was 10 times!!!! faster then the second! What's
the problem?!?!
Note: tested sql was complex enough. I didn't test this case on simple query
like 'select field1 from table1 limit 100'.

--
Sincerely,
Sergey Moroz

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Childs 2007-11-08 12:31:01 Re: "Resurrected" data files - problem?
Previous Message Albe Laurenz 2007-11-08 11:04:13 "Resurrected" data files - problem?