473,624 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Vanishing parallelism

I have a function that returns a table of information about
residential properties. The main input is a property type and
a location in grid coordinates. Because I want to get only a
certain number of properties, ordered by distance from the
location, I get the properties from a cursor ordered by distance,
and stop when the number is reached. (Not really possible to
determine the distance analytically in advance.) The cursor also
involves joins to a table of grid coordinates vs. postcodes (the
properties are identified mainly by postcode), and to a table
that maps the input property type into what types to search for.

Opening the cursor typically results in the creation of six to
eight parallel threads, and takes approx 1 second, which is about
half of the total time for the function.

Recently the main property table grew from 4 million to 6.5
million records, and suddenly the parallelism is lost. Taking
the identical code and executing it as a script gives parallelism.
Turning it into a SP that inserts into a #temp table and then
selects * from that table as the last statement also gives
parallelism. But when it's in the form of a function, there is
only one thread -- and the execution time has gone from ~2 sec
to ~8 sec. I updated the statistics on the table, but still
no parallelism.

I could turn it into a SP easily enough, but that would involve
a change to the C++ program that calls it, which takes a while
to get through the pipeline. In the meantime, is there some way
to induce the optimizer to use parallelism? It used to.

Jul 23 '05 #1
3 1554
Because (as I understand it) UDFs are implemented as macros and
recomplied every time, I assumed they would also get a new access plan
every time. However, I learned that the access plan is cached, and I
needed drop and recreate the function to have the plan updated to
reflect the new statistics for the table. That did the trick.

Jul 23 '05 #2
(ji**********@c ountrywide.com) writes:
Opening the cursor typically results in the creation of six to
eight parallel threads, and takes approx 1 second, which is about
half of the total time for the function.

Recently the main property table grew from 4 million to 6.5
million records, and suddenly the parallelism is lost. Taking
the identical code and executing it as a script gives parallelism.
Turning it into a SP that inserts into a #temp table and then
selects * from that table as the last statement also gives
parallelism. But when it's in the form of a function, there is
only one thread -- and the execution time has gone from ~2 sec
to ~8 sec. I updated the statistics on the table, but still
no parallelism.


Hm, I would not say that I have a very good answer - my problem with
parallelism is usually when I see it, when SQL Server has been over-
optimistic about the virtues of parallelism and produced a plan that
sinks the server.

But since you say that this happened when the table grew, it could be
a resource problem. Search for "parallelis m" in Books Online, and
look at the third hit. (SQL Server Architecture -> Relational Database
Engine Architecure -> Query Processor Architecture -> Parallel Query
Processing. It sounds funny that you get parallelism when you use an
SP, but it could be that you are just on the brink where parallelism
(does not) get used.

So one approach could be to throw hardware at the problem.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #3
(ji**********@c ountrywide.com) writes:
Because (as I understand it) UDFs are implemented as macros and
recomplied every time, I assumed they would also get a new access plan
every time. However, I learned that the access plan is cached, and I
needed drop and recreate the function to have the plan updated to
reflect the new statistics for the table. That did the trick.


Glad that you got it working!

Inline table functions are indeed macros - they are essentially
parameterised views. However, scalar UDFs and multi-step UDFs are
just like stored procedures in this regard and have a plan on their
own. And since your UDF involves a cursor, it has to be any of the
latter two.

Instead of reloading the function, sp_recompile on the function or
any of the tables it refers to would have been sufficient.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #4

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

Similar topics

2
1315
by: Greg | last post by:
There is a repeating issue of controls vanishing from a form in the Dev environment which is starting to get annoying. What happens is that I will have a form open in the IDE. The form will have a variety of buttons on it. The form will be saved, then compiled and run. After it runs, one or more buttons have either vanished completely, or moved to a position of 0,0. If the control vanishes completely, it may still show up when...
2
1285
by: Linda | last post by:
Greetings, I am experiencing a problem similar to that mentioned in <a href="http://groups-beta.google.com/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/a4ca8746b3de09c2/3a24082f15010830?q=controls+vanishing&rnum=1#3a24082f15010830">this post</a>, which is too old for me to respond to. Does anyone have any additional information? I am using VB.Net 2003. The Solution has two projects: one is a library project, which...
6
7091
by: paul | last post by:
hi, i've set 'max degree of parallelism' to 1 because some sql request hanged. Now when i connect, how can i set the parallelism to 4 for a session. Is there a command like this : 'alter session set max degree of parallelism 4' ? Thanks Paul
36
2483
by: TC | last post by:
I've used Access for many years. Several times, I've encountered a bug which I refer to as the "Vanishing Joins" bug. When it happens, joins vanish randomly from queries. More specifically, all joins vanish from at least one (seemingly random) query. I've always regarded the Vanishing Joins bug as a symptom of corruption. When it happens, I usually give my users advice on how to recover from corruption, and how to avoid it in the future....
0
8233
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
8675
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8474
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
7158
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
6108
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
5561
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
4078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2604
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
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.