I'm connecting to PostgreSQL using npgsql. At this time, I'm filling table in database by manually generating thousands of INSERT statements with multiple data records like
INSERT INTO tablename ( field1, field2 ) VALUES (1, "a"), (2, "b"), (3, "c") ...+ 1000 records;
and putting them to NpgsqlCommand.
How this can be done in more efficient way? I've heard about stored procedures and BULK inserts, but a good example is much needed.
The best way to fill table with data using npgsql
911 Views Asked by Arman Hayots At
1
There are 1 best solutions below
Related Questions in POSTGRESQL
- Why does adding a JOIN completely modify the query planner behaviour?
- When dealing with databases, does adding a different table when we can use a simple hash a good thing?
- Aggregate and count in PostgreSQL
- Rails HABTM: Select everything a that a record 'has'
- Trigger using data from inserted row
- Select results where joined table contains records with an attribute, but without another
- DB candidate as CouchDB/Schema replacement
- How do I properly add data in SQLAlchemy?
- Postgres in Conda Environment (Ubuntu 14.04)
- How to customize the output of the Postgres Pseudo Encrypt function?
- Split a large query (2 days) into pieces to increase the speed in Postgres
- Why does pg_search prefix not work like I expect?
- extracting meta info from a table psql using information_schema
- How to query a table in the database and copy it's data into one one?
- Update a table using info from a second table and a condition from a third table in Postgresql
Related Questions in STORED-PROCEDURES
- Optimising a slow running SQL Server Stored procedure ordered by calculated fields to return a closest match
- Oracle stored procedure wrapping compile error with inline comments
- Insert Into SP in Oracle Sql Developer
- Abstracting out a query to a stored procedure makes it run very slowly
- why it doesnt accept a concated string as parameter in SP?
- SQL Server Index recreate Stored Procedure Slow
- How to access a Row Type within an Array Type in DB2 SQL PL
- Return all Ids generated by Insert statement
- Most effective way to bind data models in WebForms without stored procedures?
- How to get result set from Oracle Stored Procedure?
- SQL Stored Procedure How to Modify and Return the Result of an Executed Dynamic Query
- How LinqToSql Generates output result of stored procedures
- pass $_post array elements of form as a string to mysql stored routines
- passing parameter values to stored procedure when calling from another procedure
- Insert Stored Procedure for One to many relationship SQL
Related Questions in INSERT
- Cell comparison and row inserts
- Insert element into nested array in Mongodb
- If numeric then Insert numeric else Insert non-numeric
- Bulk insert performance in MongoDB for large collections
- insert data from 3 tables with the same fields into 1 table
- How to insert N rows of default values into a table
- SQLite INSERT with SELECT
- Postgres INSERT from Source (2 columns) into Target (3 columns)
- check if database row is empty
- Form data not inserting in Wordpress database even though hard coded data gets inserted
- Inserting data into mysql DB with cakePHP
- oracle insert into column using subquery
- Android database store same name in database issue
- How to insert/edit records in Yii2 GridView, similar to ASP.Net
- Stored Procedure not giving expected results in Insert query
Related Questions in BULKINSERT
- MSSQL Bulk Insert CSV - Multiple columns include commas
- BULK generate data SQL Server
- PostgreSQL COPY IN and NPGSQL
- Use Bulk Insert or use default data in SQL
- EntityFramework.BulkInsert.SqlServerCe error
- Why BULK INSERT/BCP includes Sort operator although I have done everything to avoid that? (SQL Server 2012)
- The best way to fill table with data using npgsql
- Bulk insert CSV with as last column datatype bit
- Bulk insert .txt file in SQL
- Does MongoDB bulk update work for fields which don't exist
- How to Bulk Insert from XLSX file extension in SQL Server 2012?
- Mongo Bulk Insert across multiple collections
- How to insert bulk data into SQLite database in iOS using swift
- OleDbDataReader - No value given for one or more required parameters
- Elastic Search bulk indexing using perl
Related Questions in NPGSQL
- PostgreSQL COPY IN and NPGSQL
- postgresql (npgsql 2.2.5) with entity framework 6 and code first
- Parallel.ForEach using NpgsqlConnection
- The best way to fill table with data using npgsql
- Using psql options in npgsql
- Can't generate database from .edmx (Npgsql 2.2.5/EF6)
- executing a complex sql select for postgresql using c# npgsql
- npgsql preferred connection pooling usage
- How to avoid SQL Injection with Update command in Npgsql?
- PetaPoco POCO generation fails with Sequence Contains More Then One Matching Element
- Postgresql Npgsql.PostgresException in c#
- NpgSql Call function / routine
- Npgsql PostgisMultiPolygon entity type configuration Entity Framework
- Postgres date range insertion using Dapper and Npgsql
- SqlBuilder where clause for "IN" operator throws exception for comma separated
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
PostgreSQL includes a COPY feature for bulk data loading: http://www.postgresql.org/docs/9.4/static/sql-copy.html
Npgsql exposes COPY in its API. However, the next major version of Npgsql, 3.0, is still in beta and we've totally redone COPY support for it. So it wouldn't be a great idea to code for the 2.2 COPY API, only to have to migrate away from it soon. If you're OK with using beta, go with 3.0, else wait a few weeks until it's released.
Npgsql 2.2 COPY API: https://github.com/npgsql/npgsql/wiki/User-Manual (search for "Fast bulk data copy into a table")
Npgsql 3.0 COPY API: http://npgsql.github.io/npgsql/doc/copy.html (temporary URL which will change to http://www.npgsql.org/doc/copy.html)