Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Silent gratitude isn't very much use to anyone." -- G. B. Stearn


devel / comp.databases.mysql / Up to 50K inserts per second... smokin'!

SubjectAuthor
* Up to 50K inserts per second... smokin'!DFS
`* Re: Up to 50K inserts per second... smokin'!Jerry Stuckle
 +* Re: Up to 50K inserts per second... smokin'!Axel Schwenke
 |+- Re: Up to 50K inserts per second... smokin'!The Natural Philosopher
 |`- Re: Up to 50K inserts per second... smokin'!Jerry Stuckle
 `- Re: Up to 50K inserts per second... smokin'!DFS

1
Up to 50K inserts per second... smokin'!

<lFvVI.173$rl3.50@fx45.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=49&group=comp.databases.mysql#49

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx45.iad.POSTED!not-for-mail
From: nospam@dfs.com (DFS)
Subject: Up to 50K inserts per second... smokin'!
Newsgroups: comp.databases.mysql
X-Mozilla-News-Host: news://usnews.blocknews.net
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 18
Message-ID: <lFvVI.173$rl3.50@fx45.iad>
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Wed, 25 Aug 2021 18:07:13 UTC
Organization: blocknews - www.blocknews.net
Date: Wed, 25 Aug 2021 14:07:11 -0400
X-Received-Bytes: 1382
 by: DFS - Wed, 25 Aug 2021 18:07 UTC

Copying 30M rows (across 15 tables) from SQLite into a MariaDB store

Original python DB-API code did single inserts, got 5.2K per second overall.

Found some bulk insert ideas on stack exchange, finessed an
implementation and got over 50K inserts per second on some data!

"TABLEONE: 1.50 secs to post 75545 rows (50353 per sec)"

With the new code the avg for all 30M rows across all tables was around
16K per sec.

Worked on the code for some hours to save 30-45 minutes in data loading
time... but 50K inserts/sec is pretty darn good for my 11-year-old
i5-750 8GB RAM system.

Raise a glass!

Re: Up to 50K inserts per second... smokin'!

<sg6jk1$l74$1@jstuckle.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=50&group=comp.databases.mysql#50

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!jstuckle.eternal-september.org!.POSTED!not-for-mail
From: jstucklex@attglobal.net (Jerry Stuckle)
Newsgroups: comp.databases.mysql
Subject: Re: Up to 50K inserts per second... smokin'!
Date: Wed, 25 Aug 2021 19:26:52 -0400
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <sg6jk1$l74$1@jstuckle.eternal-september.org>
References: <lFvVI.173$rl3.50@fx45.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 25 Aug 2021 23:26:58 -0000 (UTC)
Injection-Info: jstuckle.eternal-september.org; posting-host="bf6e58a4502542c3d53f4b58d621f966";
logging-data="21732"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18udl2ftW7DyKDeq8guiy0Xj4uetCwNTTA="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Cancel-Lock: sha1:cBYFGQDHzpJgMZBI97NzoWGjXlA=
In-Reply-To: <lFvVI.173$rl3.50@fx45.iad>
Content-Language: en-US
 by: Jerry Stuckle - Wed, 25 Aug 2021 23:26 UTC

On 8/25/2021 2:07 PM, DFS wrote:
> Copying 30M rows (across 15 tables) from SQLite into a MariaDB store
>
> Original python DB-API code did single inserts, got 5.2K per second
> overall.
>
> Found some bulk insert ideas on stack exchange, finessed an
> implementation and got over 50K inserts per second on some data!
>
> "TABLEONE: 1.50 secs to post 75545 rows (50353 per sec)"
>
> With the new code the avg for all 30M rows across all tables was around
> 16K per sec.
>
> Worked on the code for some hours to save 30-45 minutes in data loading
> time... but 50K inserts/sec is pretty darn good for my 11-year-old
> i5-750 8GB RAM system.
>
> Raise a glass!
>

Very understandable. Each INSERT must be parsed and executed by the
RDBMS. Parsing a text SQL statement and determining how to execute it is
very time consuming, much more than actually doing the SQL statement.

That's why enterprise-level databases like IBM's DB2 have a means to
preprocess static SQL statements and build access plans to do the work.
The resultant code doesn't actually submit the SQL statement but
instead calls a function which executes the pre-built access plan.

You're inserting multiple rows with one SQL statement does the same
thing Your SQL statement only needs to be parse once and the means of
INSERTing the data only determined once. From there on it's a simple
manner of repeating the same code.

And BTW - with so many rows you'd probably get even better response by
DROPping any indices before the INSERT and recreating them after the INSERT.

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

Re: Up to 50K inserts per second... smokin'!

<sg7gff$f34$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=51&group=comp.databases.mysql#51

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: axel.schwenke@gmx.de (Axel Schwenke)
Newsgroups: comp.databases.mysql
Subject: Re: Up to 50K inserts per second... smokin'!
Date: Thu, 26 Aug 2021 09:39:27 +0200
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <sg7gff$f34$1@dont-email.me>
References: <lFvVI.173$rl3.50@fx45.iad>
<sg6jk1$l74$1@jstuckle.eternal-september.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 26 Aug 2021 07:39:27 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="865d8c606cecc2c4e2471f0b537f3fcd";
logging-data="15460"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Ys8AxflwNu23wqqc1MH5Q73oNbbtOMjU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.9.1
Cancel-Lock: sha1:d/y2YbY6ZVj9Bx3Q3AuMvt5nnu8=
In-Reply-To: <sg6jk1$l74$1@jstuckle.eternal-september.org>
Content-Language: en-US
 by: Axel Schwenke - Thu, 26 Aug 2021 07:39 UTC

On 26.08.2021 01:26, Jerry Stuckle wrote:

> Very understandable.  Each INSERT must be parsed and executed by the RDBMS.
> Parsing a text SQL statement and determining how to execute it is very time
> consuming, much more than actually doing the SQL statement.
>
> That's why enterprise-level databases like IBM's DB2 have a means to
> preprocess static SQL statements and build access plans to do the work.  The
> resultant code doesn't actually submit the SQL statement but instead calls a
> function which executes the pre-built access plan.

That's a typical Stuckle post. MySQL introduced prepared statements in
version 4.1. That was somewhere around 2005. Whopping 16 years in the past.
Yet still he tries to sell it as a feature specific to enterprise RDBMS...

Re: Up to 50K inserts per second... smokin'!

<sg7kab$8ta$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=52&group=comp.databases.mysql#52

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tnp@invalid.invalid (The Natural Philosopher)
Newsgroups: comp.databases.mysql
Subject: Re: Up to 50K inserts per second... smokin'!
Date: Thu, 26 Aug 2021 09:44:59 +0100
Organization: A little, after lunch
Lines: 24
Message-ID: <sg7kab$8ta$2@dont-email.me>
References: <lFvVI.173$rl3.50@fx45.iad>
<sg6jk1$l74$1@jstuckle.eternal-september.org> <sg7gff$f34$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 26 Aug 2021 08:44:59 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="3f8ad2ff4b758267f3c7f9f5a7498a52";
logging-data="9130"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/bCIQ5QexWukwNzg7yneWj7j/mN8O6vtk="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Thunderbird/60.6.1
Cancel-Lock: sha1:CueXeTMngGkvvmUUC+RI0a1+/Gw=
In-Reply-To: <sg7gff$f34$1@dont-email.me>
Content-Language: en-GB
 by: The Natural Philosop - Thu, 26 Aug 2021 08:44 UTC

On 26/08/2021 08:39, Axel Schwenke wrote:
> On 26.08.2021 01:26, Jerry Stuckle wrote:
>
>> Very understandable.  Each INSERT must be parsed and executed by the RDBMS.
>> Parsing a text SQL statement and determining how to execute it is very time
>> consuming, much more than actually doing the SQL statement.
>>
>> That's why enterprise-level databases like IBM's DB2 have a means to
>> preprocess static SQL statements and build access plans to do the work.  The
>> resultant code doesn't actually submit the SQL statement but instead calls a
>> function which executes the pre-built access plan.
>
> That's a typical Stuckle post. MySQL introduced prepared statements in
> version 4.1. That was somewhere around 2005. Whopping 16 years in the past.
> Yet still he tries to sell it as a feature specific to enterprise RDBMS...
>
I didn't realize stucklehead was still alive.

--
“A leader is best When people barely know he exists. Of a good leader,
who talks little,When his work is done, his aim fulfilled,They will say,
“We did this ourselves.”

― Lao Tzu, Tao Te Ching

Re: Up to 50K inserts per second... smokin'!

<sg89ta$jnk$1@jstuckle.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=53&group=comp.databases.mysql#53

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!jstuckle.eternal-september.org!.POSTED!not-for-mail
From: jstucklex@attglobal.net (Jerry Stuckle)
Newsgroups: comp.databases.mysql
Subject: Re: Up to 50K inserts per second... smokin'!
Date: Thu, 26 Aug 2021 10:53:24 -0400
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <sg89ta$jnk$1@jstuckle.eternal-september.org>
References: <lFvVI.173$rl3.50@fx45.iad>
<sg6jk1$l74$1@jstuckle.eternal-september.org> <sg7gff$f34$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 26 Aug 2021 14:53:30 -0000 (UTC)
Injection-Info: jstuckle.eternal-september.org; posting-host="bf6e58a4502542c3d53f4b58d621f966";
logging-data="20212"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199xpknlVzaz9dKIfQJowpTRmJJw6+uWtI="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Cancel-Lock: sha1:L7aCCARRsEWKd6oOo8AtfjVJts0=
In-Reply-To: <sg7gff$f34$1@dont-email.me>
Content-Language: en-US
 by: Jerry Stuckle - Thu, 26 Aug 2021 14:53 UTC

On 8/26/2021 3:39 AM, Axel Schwenke wrote:
> On 26.08.2021 01:26, Jerry Stuckle wrote:
>
>> Very understandable.  Each INSERT must be parsed and executed by the RDBMS.
>> Parsing a text SQL statement and determining how to execute it is very time
>> consuming, much more than actually doing the SQL statement.
>>
>> That's why enterprise-level databases like IBM's DB2 have a means to
>> preprocess static SQL statements and build access plans to do the work.  The
>> resultant code doesn't actually submit the SQL statement but instead calls a
>> function which executes the pre-built access plan.
>
> That's a typical Stuckle post. MySQL introduced prepared statements in
> version 4.1. That was somewhere around 2005. Whopping 16 years in the past.
> Yet still he tries to sell it as a feature specific to enterprise RDBMS...
>

MySQL's version of prepared statements is not at all like static SQL in
enterprise level databases. But you don't know the difference.

A short course. In DB2 the program is run through a preprocessor once.
The preprocessor looks for EXEC DB2 statements. When it finds one, it
analyzes te statement, builds an access plan and stores it in the
database. It then comments out the EXEC DB2 statement and builds native
language calls directly to the stored access plan to pass values and
execute the plan. The SQL code is commented out and doesn't even appear
in the compiled program.

This is NOT the same as prepared statements, which still must be
prepared every time the program hits the PREPARE statement. It is much
faster.

But you have no idea what a high performance databsae is. Compared to
DB2, MySQL is a toy

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

Re: Up to 50K inserts per second... smokin'!

<ctSZI.40448$jm6.29249@fx07.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=57&group=comp.databases.mysql#57

  copy link   Newsgroups: comp.databases.mysql
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx07.iad.POSTED!not-for-mail
From: nospam@dfs.com (DFS)
Subject: Re: Up to 50K inserts per second... smokin'!
Newsgroups: comp.databases.mysql
References: <lFvVI.173$rl3.50@fx45.iad>
<sg6jk1$l74$1@jstuckle.eternal-september.org>
X-Mozilla-News-Host: news://usnews.blocknews.net
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
MIME-Version: 1.0
In-Reply-To: <sg6jk1$l74$1@jstuckle.eternal-september.org>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 18
Message-ID: <ctSZI.40448$jm6.29249@fx07.iad>
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Tue, 07 Sep 2021 23:20:40 UTC
Organization: blocknews - www.blocknews.net
Date: Tue, 7 Sep 2021 19:20:38 -0400
X-Received-Bytes: 1595
 by: DFS - Tue, 7 Sep 2021 23:20 UTC

On 8/25/2021 7:26 PM, Jerry Stuckle wrote:
> On 8/25/2021 2:07 PM, DFS wrote:
>> Copying 30M rows (across 15 tables) from SQLite into a MariaDB store

> And BTW - with so many rows you'd probably get even better response by
> DROPping any indices before the INSERT and recreating them after the
> INSERT.

Created an Oracle Express 18c database and created 'skeleton' tables
with no PKs or FKs or indexes of any kind. Just table, column name,
datatype and NOT|NULL spec.

TBL 1: 14.88 secs to post 2799305 rows (188096 per sec)
TBL 2: 21.93 secs to post 3568564 rows (162707 per sec)
TBL 3: 110.49 secs to post 14898302 rows (134840 per sec)

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor