|
I'm experimenting with having multiple threads performing INSERTs into a table (no SELECTs, UPDATEs, or DELETEs) and I'm curious how the various IsolationLevels[^] affect performance. I have tried a few and seen no big differences. The documentation and what other information I have seen online (including here) has always seemed pretty vague to me -- and really only talks about reads (which aren't pertinent in this case).
Anyone have any insight on how IsolationLevel affects INSERTs?
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
PIEBALDconsult wrote: and really only talks about reads Because that's what could give trouble; if thread 1 does an partial update on a table, while thread 2 is reading that table - do you want the old or the new values in your result for thread 2?
I don't see any problems when multiple threads insert data. That is, if they are values - if you are reading within that insert-statement (a select, like say, the count of this table), then you might have above problem again.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: if they are values
Right, just simple insertion of values, no reading.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Rec_ID Rec_Name Dist_ID
1 A 1
2 B 1
1 AA 2
2 AB 2
3 C 2
How can i write a Insert sql script for this table, eg: i should insert Rec_ID 3 while inserting Record for Dist_ID 1 and also Rec_ID 4 for Dist_ID 2, Suppose if many users inserting from different places, how to handle this situation. what is the best method? I have following 2 ideas, which is right idea or is there any other method to implement this
1) Select Max(Rec_ID) for the district, suppose if 2 people inserting at the same time will be a issue.
2) Put a Lock in the Stored Procedure
|
|
|
|
|
Specifying Rec_ID as an identity[^] column may do all of that work for you.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
I Cannot set it as Identity column, because based on the District ID should get the Next Rec_ID
|
|
|
|
|
In which case I do not understand what you are trying to do.
Can you specify exactly what you need with a before and after example - thanks.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
modified 6-Jun-14 9:14am.
|
|
|
|
|
I'm with Guy. This does not make any sense.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Wrong order.
Insert the records in the dependent tables first, and get their identity. Then insert the REC using the identities you fetched.
Inserting data in multiple tables, appearing as a single atomic operation would require a "transaction".
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
And if the workload isn't too heavy you could use a Web Service (WCF or similar) to provide a single access point so the clients don't actually touch the database. The service could then perform the actions one-by-one.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
I have the following three tables:
TABLE_A TABLE_B TABLE_C
------- --------- -------
id (primary) tablea_id (foreign) tablea_id (foreign)
name boards text
date
phone
I have the following query to select all rows from TABLE_A and also count how many related rows are in each of the other two tables:
SELECT *, (SELECT COUNT(TABLE_B.tablea_id) FROM TABLE_B WHERE TABLE_B.tablea_id == TABLE_A.id) AS Cnt1, (SELECT COUNT(TABLE_C.tablea_id) FROM TABLE_C WHERE TABLE_C.tablea_id == TABLE_A.id) AS Cnt2 FROM TABLE_A
This works fine, but I was curious if: 1) SQL was doing three separate queries behind the scene, and 2) a more efficient way exists.
Thank you.
- DC
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
If you turn on the Execution Plan SSMS will show you the 3 queries and their relative costs. I often use this tool to compare the performance of queries constructed differently to do the same job.
I would use 3 union queries but I'd bet the cost is identical on such a simple query.
Sorry I missed the SQL Lite platform in the title
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: Sorry I missed the SQL Lite platform in the title That's okay. I could've qualified it further by stating it's running on an Android platform.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Ok
this is probably going to be the easiest answer you guys have ever given bit i am finding this concept difficult i guess it just isnt clicking
http://prntscr.com/3ps60e[^]
^picture of the table i have a question about
i am trying to fine the canidate key and the functional dependency in this table :/ i understand what a functional dependency is but cant figure out how it relates to this table for instance
CookieCost = NumberOfBoxes X $5
i know that cookie cost is functiolly dependent on the number of boxes
but yea i suppose if you could tell me the answer but more importantly HOW you got that i would REALLY appreciate it
|
|
|
|
|
Member 10865129 wrote: i know that cookie cost is functiolly dependent on the number of boxes That goes for all calculations, but that's not what's meant in the context of normalization.
Member 10865129 wrote: i am trying to fine the canidate key and the functional dependency in this table The table should be in 0NF first, in which case it needs a name. To find the candidate keys, you'd make a list of the fields that can be used to identify a unique record.
They look like meetings. What fields would the you combine to get a unique meeting - no, rephrase, which of those facts does the user require to uniquely identify an entry? If I'm not mistaken, then it's a compound key.
Next you'll be hunting for fields that are functionally dependent on a part of that key; they need to be moved to their own table (if there are any, and yes, I seen one) Ask yourself for each non-key field the question: "does this fact depend on the complete cadidate key, or is it determined by part of the candidate?"
Easy explanation; http://support.microsoft.com/kb/283878[^]
Complex explanation; http://en.wikipedia.org/wiki/Functional_dependency[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Member 10865129 wrote: more importantly HOW you got 0 NF:
Attorney | ClientNumber | ClientName | MeetingData | Duration | Boxer | 1000 | ABC, Inc | 11/5/13 | 2 | Boxer | 2000 | XYZ Partners | 11/5/13 | 5.50 | James | 1000 | ABC, Inc | 11/7/13 | 3 | Boxer | 1000 | ABC, Inc | 11/9/13 | 4 | Wu | 3000 | Malcomb Zoe | 11/11/13 | 7 |
1 NF:
* Remove all calculated facts
* Assign a key
* Move repeating groups to their own table
(key is underlined)
Attorney | ClientNumber | MeetingData | Duration | Boxer | 1000 | 11/5/13 | 2 | Boxer | 2000 | 11/5/13 | 5.50 | James | 1000 | 11/7/13 | 3 | Boxer | 1000 | 11/9/13 | 4 | Wu | 3000 | 11/11/13 | 7 |
ClientNumber | ClientName | 1000 | ABC, Inc | 2000 | XYZ Partners | 3000 | Malcomb Zoe |
2 NF:
* Find the attributes that are not "functionally dependent" on the entire key
That means that we look at each non-key field and ask ourselves whether or not it is depending on the entire key, or whether it can be identified with a part of that key.
The only non-key field in "Meetings" is called "Duration". The duration "2" belongs to the meeting that's identified with all three fields, so there's no functional dependency there. In the original table the duration could depend on a part of the key; my mistake.
3NF:
* Find non-key fields that depend on other non-key fields.
There's none.
One might argue that the Attorney is also a repeating group, and put it in it's own table with an artificial key.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have created SSIS package and deployed in SQL Server 2008 in a seprate server, and that package is called using ASP.NET which is different web server, in this web server i have already installed Integration Services, but still when i load the package i am getting below error message.
package errMicrosoft.SqlServer.Dts.Runtime.DtsComException: An Integration Services class cannot be found. Make sure that Integration Services is correctly installed on the computer that is running the application. Also, make sure that the 64-bit version of Integration Services is installed if you are running a 64-bit application. ---> System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {BA785E28-3D7B-47AE-A4F9-4784F61B598A} failed due to the
following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). at Microsoft.SqlServer.Dts.Runtime.Application..ctor()
can you please help if am missing any settings or runtime service to be installed in web server.
Below is my code that is used to execute the SSIS Package.
Dim pkg As Package
Dim app As Application
Dim pkgResult As DTSExecResult
app = New Application()
pkg = app.LoadFromSqlServer("\\" & SSISPackageName, DB_ServerAddress, Nothing, Nothing, Nothing)
pkgResult = pkg.Execute()
If (pkgResult = DTSExecResult.Failure) Then
For Each local_DtsError As Microsoft.SqlServer.Dts.Runtime.DtsError In pkg.Errors
Next
End If
Shuaib
|
|
|
|
|
Hello All,
I tried using '+' operator for left outer join in MySql Workbench 5.2 CE but it is giving me a syntax error.I want to know whether + operator is supported by MySql Workbench 5.2 CE or not?I have gone through the manual of workbench but I did not find any information on this topic.Kindly help me with it.
|
|
|
|
|
I'm pretty sure MySQL isn't supporting outer implicit joins, only inner implicit joins.
You'll have to use an Ansi Join instead.
|
|
|
|
|
Lots of companies are comparing the SSAS Tabular vs Multi-dimensional Model. Honestly, there are tons and tons of articles already written about the differences between the two (so i don’t plan on doing that). Case in Point: http://www.sqlchick.com/entries/2012/3/4/decisions-powerpivot-ssas-tabular-or-ssas-multidimensional-m.html
I recently worked in an environment where we were looking at using data-mining algorithms for product affinity analysis, linear regression and customer analysis for generating customer mailing lists.
Unfortunately, way back, the decision had been made to go with Tabular model, to take advantage of the the InMemory and speed of development benefits. Now, with tabular in place, requests starts coming for analysis that requires the construction of data-mining structures akin to what is in Multi-dimensional. Unfortunately, that functionality doesn’t exist in Tabular yet, so we can’t do the analysis unless we go Multi-dimensional.
Fortunately, this is not a show-stopper requirement for us but just something to be aware off.
Summary: Currently, tabular model does not support data mining structures required for product affinity analysis, linear regression, customer predictive analysis, e.t.c. I’m not sure if Microsoft plans on building such functionalities into Tabular model going forward, but I just wanted to point it out incase some people are not yet aware of this short coming for Tabular.
|
|
|
|
|
I am sick to the back teeth of encoding issues with MySQL. I have Googled the issue and tried every suggestion I can find, and am still plagued with insert errors such as:
ERROR [HY000] [MySQL][ODBC 5.1 Driver][mysqld-5.5.18]Incorrect string value: '\xEF\x82\xA7\x09Se...' for column '[column name]' at row 1
Please.. don't bother suggesting ways round this, I give up on it. My question, to anyone else who has experienced this, is simply this: does PostgreSQL suffer this same issue, or at least have a solution that works?
|
|
|
|
|
It will have different issues.
Your best bet is to make sure you install it to use Unicode. But watch out, PostGreSQL uses UTF8 while dotnet uses UTF16 internally. So you might still encounter odd issues.
MySQL supports UTF16 from version 5.5 IIRC.
Why do you use odbc instead of Connector/NET?
|
|
|
|
|
It was installed with utf8_geberal_ci as the default. With the later versions of MySQL supporting utf8mb4_general_ci I've tried that too - but to no avail.
Why ODBC? Habit, I guess. Would Connector/NET make a difference?
|
|
|
|
|
Wombaticus wrote: Would Connector/NET make a difference?
Mostly performance, and a lot of it.
Have you read this[^]?
|
|
|
|
|
Hi All,
I have the following query that is created by MS Access while creating report. But the query has lots of inner queries and joins. Can anybody please help in making this big query simple and by removing all the possible brackets and make it clean. Any type is very helpful. This query really taking a lot of time to understand it. Any link, tool name or way to solve it any help is very much helpful. Thanks in advance.
Here is the query.
SELECT so.EntityId, s.SponsorId, so.OrderId, so.ProgramId, so.ProgramYear, s.SponsorNbr,
s.SponsorNme, s.VendorNbr, s.MailFdpCde, dbo.Reference.RefCde, dbo.Reference.ExtCde, dbo.FDPSponsorApp.CurrentInd,
dbo.DeliveryPeriod.BegDte, dbo.DeliveryPeriod.EndDte, dbo.vwRef_fdpprogram.RefDsc, dbo.vwRef_fdpprogram.RefCde AS ProgramCde, dbo.Product.ProductCde,
dbo.Product.ShortDsc as ProductDsc, sod.QtyInv AS QtyRcv, dbo.Product.NetPackWt,
(CASE WHEN ((dbo.ProductCost.FixedCost IS NULL) OR (dbo.ProductCost.EntDrawInd= 653)) THEN ISNULL(dbo.ProductCost.WghtAvgCost, 0)
ELSE ISNULL(dbo.ProductCost.FixedCost,0) END) AS UnitCost,
[QtyInv]*(CASE WHEN ((dbo.ProductCost.FixedCost IS NULL) OR (dbo.ProductCost.EntDrawInd= 653)) THEN ISNULL(dbo.ProductCost.WghtAvgCost, 0)
ELSE ISNULL(dbo.ProductCost.FixedCost,0) END) AS ValueRcvd,
[NetPackWt]*[QtyInv] AS [Total Pounds], dbo.Contact.FirstNme, dbo.Contact.LastNme, dbo.Address.Addr1, dbo.Address.Addr2,
dbo.Address.City, dbo.Address.State, dbo.Address.ZipCde, dbo_Reference_1.RefDsc AS DeliveryType, so.DeliveryTypeId,
dbo.RefYearDefaults.DefValue AS BrownBoxFee, dbo_RefYearDefaults_1.DefValue AS DirectDiversionFee, dbo.Product.NetPackWt, s.VendorNbr,
s.FedEmpIdNbr
FROM dbo.RefYearDefaults AS dbo_RefYearDefaults_1
INNER JOIN (dbo.RefYearDefaults
INNER JOIN ((dbo.Reference
INNER JOIN ((dbo.Contact
INNER JOIN (dbo.Address
INNER JOIN (dbo.ProductCost
INNER JOIN (dbo.Sponsor s
INNER JOIN (dbo.FDPSponsorApp
INNER JOIN ((((dbo.FDPEntity
INNER JOIN dbo.SponsorOrder so ON dbo.FDPEntity.EntityId = so.LocationId)
INNER JOIN dbo.SponsorOrderDetail sod ON so.OrderId = sod.OrderId)
INNER JOIN dbo.Product ON sod.ProductId = dbo.Product.ProductId)
INNER JOIN dbo.DeliveryPeriod ON (so.DeliveryPeriodId = dbo.DeliveryPeriod.DeliveryPeriodId)
AND (so.ProgramYear = dbo.DeliveryPeriod.ProgramYear)) ON (dbo.FDPSponsorApp.EntityId =
so.EntityId) AND (dbo.FDPSponsorApp.ProgramYear = so.ProgramYear)) ON s.SponsorId = dbo.FDPSponsorApp.SponsorId) ON
(dbo.ProductCost.ProgramYear = dbo.FDPSponsorApp.ProgramYear) AND (dbo.ProductCost.ProductId = dbo.Product.ProductId)) ON dbo.Address.AddrId =
dbo.FDPSponsorApp.MailAddrId) ON dbo.Contact.ContactId = dbo.FDPSponsorApp.FdpCtcId) INNER JOIN dbo.vwRef_fdpprogram ON so.ProgramId =
dbo.vwRef_fdpprogram.RefId) ON dbo.Reference.RefId = s.SFMSObjectTypeId) INNER JOIN dbo.Reference AS dbo_Reference_1 ON so.DeliveryTypeId =
dbo_Reference_1.RefId) ON dbo.RefYearDefaults.ProgramYear = so.ProgramYear) ON dbo_RefYearDefaults_1.ProgramYear = so.ProgramYear
WHERE (((so.ProgramYear)= 2014) AND --so.EntityId = @SponsorEntityId AND
((dbo.FDPSponsorApp.CurrentInd)=1) AND ((sod.QtyInv)>0) AND ((dbo.RefYearDefaults.DefNme)='BrownBoxFee')
AND ((dbo_RefYearDefaults_1.DefNme)='DirectDiversionFee')) ORDER BY so.EntityId, s.SponsorNme, so.OrderId, Product.ShortDsc
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|