The other day I found myself musing about inter-query parallelisation. Not intra-query that we know and love where the optimizer chooses parallel operators depending on MAXDOP (for the SQL Server world). Instead, I'm talking about inter-statement parallelisation such as "INSERT these rows in this table and while that's happening INSERT those rows in that other table; when they're both finished do this."
Sometimes an overly large query produces a poor plan. Splitting the query then combining the temporary results set is one strategy for getting a better plan. If the part-queries could be executed in parallel run time would be reduced.
Has anyone come across papers, blogs or interwebz chatter on this topic? Or is this just crazy-talk?
MicroVersion: Planned service degradation: All Stack Overflow/Stack Exchange sites read-only for 20 minutes on Wed, May 3, 2017 shortly after 8PM US/Eastern (midnight UTC). If you blink, you'll miss it.
Short version:
There will be a service degradation for up to 20 minutes shortly after 8PM US...
@swasheck Depends what you define by 'works well.' If you ask the CFO (as I did once) he was happy with it because they'd been able to free up a whole load of money tied up in inventory and implement some process efficiencies. If you ask all the engineers with homebrew access databases they'd say it never works as well as what they'd done themeselves.
If by 'works well' you mean 'easy to integrate with', that really depends on whether you're an end user or a SAP consulting form. It's all a matter of perspective.
@Mathematics Perhaps. But searching the Internet is, in a way, like asking a question in an enormous chat room. If you think that the global "chat room" can hardly give you an easy solution, then how do you rate your chances asking around here? :)
@Mathematics I don't have much knowledge about change tracking but I guess I could give you some pointers by googling. I was just curious why you yourself wouldn't take that course of action before coming here.
@Mathematics I have no issues with your being here, and I can promise you I will have no issues with your asking questions here from now on. Looking back, I guess my reaction may have come across as passive aggressiveness but there was genuine curiosity in my question. Sorry about any trouble caused.
Just answering to help you with curiosity, I did came up with a prototype which works, but I am not happy with architecture, so I thought because this is such a common scenario I might get some insights.
In field of architecture it's difficult to get help from google, there are strategies but they take more time.
Or in other words... google don't help with such queries (I know we can search anything on google but we have to be smart right ? won't going to spend months searching for something...)
@ypercubeᵀᴹ it's random sometime it's only once or twice a day and other days like 100s and it's modified using custom code which is using stored procedures
@Mathematics That's all very fair, but when you are asking for help (as opposed to searching the Internet), it really helps those whom you are asking to know what you have already tried. You asked your question broadly without even mentioning the fact that you'd already done some research. It really looked like a lazy question to me.
I have a silly rookie problem. I am trying to transpose a table of "settings" which is one row with about 100 columns e.g `Locator, WOMEN_LB, MEN_LB`. The only row would contain those setting values. `UNPIVOT` seems like what I want but I don't want to do any aggregation on the data (like most of the existing questions cover), just transpose. I could easily use Dynamic SQL for this but I figured there was a better way. I can only get it to work for the one column..
DECLARE @S AS table (v1 integer, v2 integer, v3 integer);
INSERT @S VALUES (1, 2, 3);
SELECT U.[name], U.[value]
FROM @S AS S
UNPIVOT ([value] FOR [name] IN (v1, v2, v3)) AS U;
When applying the UNPIVOT function to data that is not normalized, SQL Server requires that the datatype and length be the same. I understand why the datatype must be the same but why does UNPIVOT require the length to be the same?
Let's say that I have the following sample data that I need to ...
so i'm reading things that note that you can't change a database's default isolation level while it's participating in an availability group but that's not what i'm experiencing right now.
alter database [foo] set read_committed_snapshot on
with rollback immediate
@swasheck Where are you reading that? I know little about AGs, but if that's true, I would expect it to relate to SI not RCSI and on the secondary only.
@JoeObbish thanks @JoeObbish. In the past I've built Agent job streams that run in parallel, and that works well. The use case I'm contemplating here is OLTP related where a single business task consists of several separate non-dependent steps. The response time would be reduced if the steps could run in parallel.
The link gives a clear example of how to use "HierarchyId" data type for a database column. And also the page show cases, how it can be queried. It is self-explanatory. No better example can be given on top of this. — Loganathanpc30 mins ago
@TomV Yes, I can see how SSIS would achieve this. I can't figure out how to call out to it from an existing stack of stored procedure calls, however. It could be done in the application layer, too, in a MARS-like way, but then intermediate results have to travel over the network and the app must reimpliment a join algorithm. I was wondering if it could be coordinated through SQL CLR. When I get a moment I'll try it out.
@JoeObbish I see what you mean. From within the OLTP task call sp_start_job which will then perform the sub-task asynchronously. Yes, that would do it. Would have to think of a way to wait for a number of async. stream to finish. Polling would do it but risks adding latency, and the idea is to minimise latency. IIRC each job has its own connection so locking would have to be considered carefully, though there are ways around that, too.
This is just a Gedankenexperiment, BTW. No actual application will be hurt during the implementation of this prototype.
@billinkc When I implemented this in application code I used threads and OS messages to signal completion. So Service Broker is the closest analogy in the DB realm. Is it possible to return control to the SP that started the chain? Hmmm .. I'll have to look into that. Thanks!