473,800 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forcing a stored procedure recompile

Hello everyone.

Can anyone suggest if there's a way to force a plpgsql stored procedure
to be recompiled every time that it's called, based on the values of the
parameters that it's given? I assumed it would be possible, but
unfortunately haven't been able to find any documentation on how to
force a recompile at all, let alone automatically.

I've encountered a situation where the standard precompiled generic
query plan isn't working at all well with the unknown variables that the
stored procedure receives. It seems to do nicely if I replace them with
constants, though. (Compilation time isn't really an issue in this
situation, but I'd like to leave everything in the stored procedure for
other reasons.)

I could probably re-write the procedure to concatenate a string
containing the unknowns as constants and then EXECUTE it. Doing it that
way seems a bit ugly, though, and it'd make maintenance a bigger problem.
Thanks in advance for any help or suggestions.
Mike.
Nov 23 '05 #1
1 2392
Mike McGavin wrote:
Hello everyone.

Can anyone suggest if there's a way to force a plpgsql stored procedure
to be recompiled every time that it's called, based on the values of the
parameters that it's given? I assumed it would be possible, but
unfortunately haven't been able to find any documentation on how to
force a recompile at all, let alone automatically.

I've encountered a situation where the standard precompiled generic
query plan isn't working at all well with the unknown variables that the
stored procedure receives. It seems to do nicely if I replace them with
constants, though. (Compilation time isn't really an issue in this
situation, but I'd like to leave everything in the stored procedure for
other reasons.)

I could probably re-write the procedure to concatenate a string
containing the unknowns as constants and then EXECUTE it. Doing it that
way seems a bit ugly, though, and it'd make maintenance a bigger problem.


Right now unfortunately this is the only one solution.

See the post on performance (8/28/2004) with the title:

ill-planned queries inside a stored procedure"


Regards
Gaetano Mendola
Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4313
by: P | last post by:
I would like to call my stored proc and invoke the WITH RECOMPILE option. I can't figure out what to set in ADO to make that happen. Anyone know how to make this work? BTW, I _don't_ want to create the stored proc using the WITH RECOMPILE.
12
8354
by: serge | last post by:
I have an SP that is big, huge, 700-800 lines. I am not an expert but I need to figure out every possible way that I can improve the performance speed of this SP. In the next couple of weeks I will work on preparing SQL statements that will create the tables, insert sample record and run the SP. I would hope people will look at my SP and give me any hints on how I can better write the SP.
10
3747
by: Thomas R. Hummel | last post by:
I have a stored procedure that suddenly started performing horribly. The query plan didn't look right to me, so I copy/pasted the code and ran it (it's a single SELECT statement). That ran pretty well and used a query plan that made sense. Now, I know what you're all thinking... stored procedures have to optimize for variable parameters, etc. Here's what I've tried to fix the issue: 1. Recompiled the stored procedure 2. Created a new,...
5
2184
by: Magnus Österberg | last post by:
My application fetches a batch of data through a web service and writes 1000 entities per batch to a SQL Server 2000 database. There are 4 tables in every batch. There are the following number of SQL commands executed per average of every batch; Table #1: always 1 Table #2: 5 Table #3: 5 Table #4: 3
1
2404
by: Alex | last post by:
Hi all, Just been dabbling with java stored procedures and I'm having problems replacing System: db2 8.1.4 on RH 7.1 linux system 1). Look at java jdbc samples as supplied with db2 and run the SpServer and Spclient progs against the default database SAMPLE. And everything works.
8
1312
by: Steven Blair | last post by:
Hi, I have a system which processes 1000's of transactions per hour. Part of each transaction process invloves me calling a stored procdure which updates various tables. What I want to know is, is a Stored Procedure like a function in terms of performance, each time the SP is about to get called, the function will have memory allocated for it on the stack(including all variables required). So, this process would happen however many...
45
3419
by: John | last post by:
Hi When developing vb.bet winform apps bound to sql server datasource, is it preferable to use SELECTs or stored procedure to read and write data from/to SQL Server? Why? Thanks Regards
28
72571
by: mooreit | last post by:
The purpose for my questions is accessing these technologies from applications. I develop both applications and databases. Working with Microsoft C#.NET and Microsoft SQL Server 2000 Production and 2005 Test Environments. What is the purpose of a view if I can just copy the vode from a view and put it into a stored procedure? Should I be accessing views from stored procedures?
12
2306
by: Jason Huang | last post by:
Hi, In my C# Windows Form application project, I have done all queries on my codes. Now I wanna try using the Stored Procedure. But I am not clear about why using the stored procedure. Would some one give me some advice? Thanks for help.
0
9689
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10248
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7573
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.