Home Database Mysql Tutorial .NET批量大数据插入性能分析及比较(6.使用表值参数)

.NET批量大数据插入性能分析及比较(6.使用表值参数)

Jun 07, 2016 pm 03:14 PM
.net use analyze performance insert data Compare

表值 参数 (Table-valued Parameter)是SQL Server 2008增加的新特性,可以将DataTable做为 参数 传递给存储过程。 数据 库执行脚本如下 CREATE TYPE TestType AS TABLE ( Id int NOT NULL ,Name nvarchar(20) NOT NULL ) CREATE PROC InsertData @rows TestT

 

表值参数(Table-valued Parameter)是SQL Server 2008增加的新特性,可以将DataTable做为参数传递给存储过程。

 

数据库执行脚本如下

CREATE TYPE TestType AS TABLE
(
 Id int NOT NULL
 ,Name nvarchar(20) NOT NULL
)

CREATE PROC InsertData
 @rows TestType READONLY
as
begin
 set nocount on
 insert into TestTable(Id, Name)
 select Id, Name from @rows
end

 

 

代码如下:

 

结果如下:

Use SqlServer TableType Insert;RecordCount:40000;BatchSize:10;Time:15312;

Use SqlServer TableType Insert;RecordCount:40000;BatchSize:20;Time:7806;

Use SqlServer TableType Insert;RecordCount:40000;BatchSize:50;Time:3767;

Use SqlServer TableType Insert;RecordCount:40000;BatchSize:100;Time:2217;

Use SqlServer TableType Insert;RecordCount:40000;BatchSize:200;Time:1743;

Use SqlServer TableType Insert;RecordCount:40000;BatchSize:400;Time:1575;

Use SqlServer TableType Insert;RecordCount:40000;BatchSize:500;Time:1566;

Use SqlServer TableType Insert;RecordCount:40000;BatchSize:600;Time:1374;

Use SqlServer TableType Insert;RecordCount:40000;BatchSize:700;Time:1286;

Use SqlServer TableType Insert;RecordCount:40000;BatchSize:800;Time:1463;

Use SqlServer TableType Insert;RecordCount:40000;BatchSize:1000;Time:1272;

Use SqlServer TableType Insert;RecordCount:40000;BatchSize:2000;Time:1069;

Use SqlServer TableType Insert;RecordCount:40000;BatchSize:4000;Time:1001;

 

从时间上来看,似乎并不必前面的案例强,但批处理量得增加,写性能在持续提高,而且实际上程序中花费了大量的时间在创建DataTable及填充其数据上面,如果传递给函数的就是一个DataTable集合,相信使用表值参数的表现会更好。

 

但考虑到需要为插入的表创建类型,创建存储过程,个人认为其通用性不是很好

 

全文链接:

.NET批量大数据插入性能分析比较(1.准备工作)

.NET批量大数据插入性能分析比较(2.普通插入与拼接sql批量插入)

.NET批量大数据插入性能分析比较(3.使用事务)

.NET批量大数据插入性能分析比较(4.使用DataAdapter批量插入)

.NET批量大数据插入性能分析比较(5.使用SqlBulkCopy)

.NET批量大数据插入性能分析比较(6.使用表值参数)

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Slow Cellular Data Internet Speeds on iPhone: Fixes Slow Cellular Data Internet Speeds on iPhone: Fixes May 03, 2024 pm 09:01 PM

Facing lag, slow mobile data connection on iPhone? Typically, the strength of cellular internet on your phone depends on several factors such as region, cellular network type, roaming type, etc. There are some things you can do to get a faster, more reliable cellular Internet connection. Fix 1 – Force Restart iPhone Sometimes, force restarting your device just resets a lot of things, including the cellular connection. Step 1 – Just press the volume up key once and release. Next, press the Volume Down key and release it again. Step 2 – The next part of the process is to hold the button on the right side. Let the iPhone finish restarting. Enable cellular data and check network speed. Check again Fix 2 – Change data mode While 5G offers better network speeds, it works better when the signal is weaker

Tesla robots work in factories, Musk: The degree of freedom of hands will reach 22 this year! Tesla robots work in factories, Musk: The degree of freedom of hands will reach 22 this year! May 06, 2024 pm 04:13 PM

The latest video of Tesla's robot Optimus is released, and it can already work in the factory. At normal speed, it sorts batteries (Tesla's 4680 batteries) like this: The official also released what it looks like at 20x speed - on a small "workstation", picking and picking and picking: This time it is released One of the highlights of the video is that Optimus completes this work in the factory, completely autonomously, without human intervention throughout the process. And from the perspective of Optimus, it can also pick up and place the crooked battery, focusing on automatic error correction: Regarding Optimus's hand, NVIDIA scientist Jim Fan gave a high evaluation: Optimus's hand is the world's five-fingered robot. One of the most dexterous. Its hands are not only tactile

The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times. The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times. May 07, 2024 pm 05:00 PM

Recently, the military circle has been overwhelmed by the news: US military fighter jets can now complete fully automatic air combat using AI. Yes, just recently, the US military’s AI fighter jet was made public for the first time and the mystery was unveiled. The full name of this fighter is the Variable Stability Simulator Test Aircraft (VISTA). It was personally flown by the Secretary of the US Air Force to simulate a one-on-one air battle. On May 2, U.S. Air Force Secretary Frank Kendall took off in an X-62AVISTA at Edwards Air Force Base. Note that during the one-hour flight, all flight actions were completed autonomously by AI! Kendall said - "For the past few decades, we have been thinking about the unlimited potential of autonomous air-to-air combat, but it has always seemed out of reach." However now,

AI startups collectively switched jobs to OpenAI, and the security team regrouped after Ilya left! AI startups collectively switched jobs to OpenAI, and the security team regrouped after Ilya left! Jun 08, 2024 pm 01:00 PM

Last week, amid the internal wave of resignations and external criticism, OpenAI was plagued by internal and external troubles: - The infringement of the widow sister sparked global heated discussions - Employees signing "overlord clauses" were exposed one after another - Netizens listed Ultraman's "seven deadly sins" Rumors refuting: According to leaked information and documents obtained by Vox, OpenAI’s senior leadership, including Altman, was well aware of these equity recovery provisions and signed off on them. In addition, there is a serious and urgent issue facing OpenAI - AI safety. The recent departures of five security-related employees, including two of its most prominent employees, and the dissolution of the "Super Alignment" team have once again put OpenAI's security issues in the spotlight. Fortune magazine reported that OpenA

Performance comparison of different Java frameworks Performance comparison of different Java frameworks Jun 05, 2024 pm 07:14 PM

Performance comparison of different Java frameworks: REST API request processing: Vert.x is the best, with a request rate of 2 times SpringBoot and 3 times Dropwizard. Database query: SpringBoot's HibernateORM is better than Vert.x and Dropwizard's ORM. Caching operations: Vert.x's Hazelcast client is superior to SpringBoot and Dropwizard's caching mechanisms. Suitable framework: Choose according to application requirements. Vert.x is suitable for high-performance web services, SpringBoot is suitable for data-intensive applications, and Dropwizard is suitable for microservice architecture.

PHP array key value flipping: Comparative performance analysis of different methods PHP array key value flipping: Comparative performance analysis of different methods May 03, 2024 pm 09:03 PM

The performance comparison of PHP array key value flipping methods shows that the array_flip() function performs better than the for loop in large arrays (more than 1 million elements) and takes less time. The for loop method of manually flipping key values ​​takes a relatively long time.

Share several .NET open source AI and LLM related project frameworks Share several .NET open source AI and LLM related project frameworks May 06, 2024 pm 04:43 PM

The development of artificial intelligence (AI) technologies is in full swing today, and they have shown great potential and influence in various fields. Today Dayao will share with you 4 .NET open source AI model LLM related project frameworks, hoping to provide you with some reference. https://github.com/YSGStudyHards/DotNetGuide/blob/main/docs/DotNet/DotNetProjectPicks.mdSemanticKernelSemanticKernel is an open source software development kit (SDK) designed to integrate large language models (LLM) such as OpenAI, Azure

How to optimize the performance of multi-threaded programs in C++? How to optimize the performance of multi-threaded programs in C++? Jun 05, 2024 pm 02:04 PM

Effective techniques for optimizing C++ multi-threaded performance include limiting the number of threads to avoid resource contention. Use lightweight mutex locks to reduce contention. Optimize the scope of the lock and minimize the waiting time. Use lock-free data structures to improve concurrency. Avoid busy waiting and notify threads of resource availability through events.

See all articles