Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Does two SQL server execute two queries in parallel?

$
0
0
I have two heavy queries to run, and both of them take about 1 minute to run. Both queries are using Bulk Insert command to insert data from txt files to tables in the database. For the two target tables, no index/trigger/constraints, just two empty tables to import data.

Query 1:

`Bulk insert table1
FROM 'table1.txt'  WITH
        (FIELDTERMINATOR ='|',
ROWTERMINATOR = '0x0a',
TABLOCK)`

Query 2:

`Bulk insert table2 FROM 'table2.txt'
FROM 'table2.txt'  WITH
        (FIELDTERMINATOR ='|',
ROWTERMINATOR = '0x0a',
TABLOCK)`

I want to compare the running time under different scenarios

Scenario 1: two queries running serially in one editor:

  • Query 1: 1 m 18 s
  • Query 2: 1 m 2 s

Scenario 2: each query in a separate editor of the SAME STUDIO, running concurrently:

  • Query 1: 2 m 36 s
  • Query 2: 2 m 09 d

Scenario 3: each query in a SEPARATE STUDIO, running concurrently:

  • Query 1: 2 m 29 s
  • Query 2: 2 m 19 s

For all scenarios,no significant differences between the usage of CPU and disk are observed. I am wondering what's happening under the hood? How does the sql server execute these queries?

I'm using sql server 2016 developer version on windows 10 64 bit.

Thanks in advance for your help!

Jason

Update:

After testing more scenarios with 4 queries running together, I think the possible cause of low usage of CPU and disk is the hyperthreading with my core i7:

  • With two editors running two queries concurrently, the most CPU usage is 25%.

  • With 4 editors running 4 queries concurrently, the most CPU usage is 50%.

Are you guys aware of ways to let one query exclusively use one core? Turning off hyperthreading is not an option for me, since my thinkpad t460p doesn't support such option in the bios.



Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>