<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Gigashock on Stephen Krings</title>
    <link>https://stephenkrings.com/tags/gigashock/</link>
    <description>Recent content in Gigashock on Stephen Krings</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Fri, 05 Feb 2021 14:20:00 -0800</lastBuildDate>
    <atom:link href="https://stephenkrings.com/tags/gigashock/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>10,000 &#34;Inserts&#34; Per Minute Without a High Performance Database</title>
      <link>https://stephenkrings.com/posts/6000-inserts-per-minute-without-high/</link>
      <pubDate>Fri, 05 Feb 2021 14:20:00 -0800</pubDate>
      <guid>https://stephenkrings.com/posts/6000-inserts-per-minute-without-high/</guid>
      <description>&lt;p&gt;&lt;strong&gt;from my archived blog &lt;a href=&#34;http://blog.gigashock.com/&#34;&gt;blog.gigashock.com&lt;/a&gt;. reposted here.&lt;/strong&gt;&lt;/p&gt;
&lt;p style=&#34;text-align: center;&#34;&gt;&lt;a href=&#34;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDYCLDeN-Oit9iYhEcZVbkUL7d9wbNIoTt0pc_LLGXAI1COmYf2H_EVNwSNZ7LIcvy2RPgdhuMyNhfg9b1oD99CUH_CQq5qVjoJ0uMPv3CZLgakoOOrPj3efeyUje2yJOZijyCmUxtLLA/s300/Untitled-1.png&#34; style=&#34;font-family: Arial; font-size: 11pt; margin-left: 1em; margin-right: 1em; white-space: pre-wrap;&#34;&gt;&lt;img src=&#34;https://stephenkrings.com/images/gigashock/6000-inserts-per-minute-without-high/image-01-996be99202.png&#34;/&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;a href=&#34;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnX0sHxzSVn8NwZP-ZddX74MZlD-faXTfdXWEMivi8er7isY6Snjmwk4LRTJ-IDkfxJU21OgC2FAbR0hVALINXq9Trm78kaNZ_p5Edzhczs-AvtLEdVK3DeBh2iwgGnXEtCidOgxex12Q/s159/stephen_profile_blogger.png&#34; style=&#34;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; white-space: pre-wrap;&#34;&gt;&lt;img height=&#34;168&#34; src=&#34;https://stephenkrings.com/images/gigashock/6000-inserts-per-minute-without-high/image-02-044efb2c3d.png&#34; width=&#34;168&#34;/&gt;&lt;/a&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;By &lt;/span&gt;&lt;a href=&#34;https://www.linkedin.com/in/stephenkrings/&#34; style=&#34;font-family: courier;&#34; target=&#34;_blank&#34;&gt;Stephen Krings&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;p style=&#34;background-color: white; text-align: center;&#34;&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Former Security Operations Engineer at&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt; &lt;span style=&#34;color: black;&#34;&gt;&lt;a href=&#34;https://www.cloudflare.com/&#34; target=&#34;_blank&#34;&gt;Cloudflare, Inc&lt;/a&gt;&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;a href=&#34;http://github.com/kringz&#34; target=&#34;_blank&#34;&gt;github.com/kringz&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;a href=&#34;http://twitter.com/stephenkrings&#34;&gt;twitter.com/stephenkrings&lt;/a&gt;&lt;br/&gt;email: stephen &amp;lt;at&amp;gt; gigashock *dot* com&lt;br/&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;br/&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;b&gt;Why&lt;br/&gt;&lt;br/&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;There are 1440 minutes in a day and I don&#39;t like waiting.&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;10,000 inserts per minute isn&#39;t that impressive for a database. All databases can be easily optimized to perform at such speeds. In this case, however, I had a simple Python script that I needed to run many, many times over and a way to keep track of which data I had retrieved and which data I had not.&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;It&#39;s important to note that I had permission to make these requests to the remote server. Making this many parallel requests to a remote server without permission could cause Denial-of-Service to the unsuspecting host.&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;b&gt;The Problem&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;b&gt;&lt;br/&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;I have a remote server with&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt; 2 million&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt; individual &lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;text files. Each text file has information that needs to be extracted and inserted into a database table.&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;I could not for the life of me get MySQL + Python to get me more than a few hundred inserts per minute.&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Initially, I wrote a Python script to open each remote text file, extract the data and insert it directly into a SQL table. &lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Despite decent hardware on the database server (128GB of RAM, 8 core, 16 thread &lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;3.7GHz processor)&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;, I was bogged down by the volume of inserts required for this task. &lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;b&gt;Old Script&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;div style=&#34;clear: both; text-align: center;&#34;&gt;&lt;a href=&#34;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqTpD35jeL9xxsy4jJOw4ukZP7H8TUmBQfiRLW5WhXbrU7YmaGlDqjnZcq2GakCdXbwm1qytz0Mkv7Eo3ZF0QVmwqYrxBg_XD6EU3BWlafxsuaMIyMk_8uXa57B6CTNxYnRvgjr0OXSj0/s861/1+%25281%2529.png&#34; style=&#34;margin-left: 1em; margin-right: 1em;&#34;&gt;&lt;img height=&#34;358&#34; src=&#34;https://stephenkrings.com/images/gigashock/6000-inserts-per-minute-without-high/image-03-6152ec4138.png&#34; width=&#34;640&#34;/&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&#34;clear: both; text-align: center;&#34;&gt;&lt;br/&gt;&lt;/div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;This was a serial solution. One file was retrieved and the data inserted into MySQL at a time. &lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Rather than waiting 4 days for the task to complete with a single for-loop, I decided to take a different approach: &lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;1. Minimize MySQL&#39;s role&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;2. Allow for the script to be run many times in parallel&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;b&gt;The New Script &lt;/b&gt;(&lt;a href=&#34;https://github.com/kringz/file_retriever/blob/main/pull.py&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;b&gt;&lt;br/&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;clear: both; text-align: center;&#34;&gt;&lt;a href=&#34;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcdo0pWmMKtAVnRqTkhADBeqnWs57H-cAZT3tMbuzkPpfBHbwJh3pDDG1cJsEGv_MgTH0ecb97tGXBDTKxsxEJZiHP1X9BIvfsPX9vr-AtSYtC6dq1iKszjz1IRI0K-j76I3Rt8T5P9EU/s946/2+%25281%2529.png&#34; style=&#34;margin-left: 1em; margin-right: 1em;&#34;&gt;&lt;img height=&#34;522&#34; src=&#34;https://stephenkrings.com/images/gigashock/6000-inserts-per-minute-without-high/image-04-aed6409ef6.png&#34; width=&#34;640&#34;/&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&#34;clear: both; text-align: center;&#34;&gt;&lt;br/&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;The main issue, I suspect, was that the first script I wrote was only running a &lt;i&gt;single&lt;/i&gt; loop through the 2 million text files and could not be efficiently run many times at once because it would have to check the final database table to see if the file contents had already been entered by another script.&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;The solution to this in the new script was to track progress in a queuing table in MySQL to keep track of which files had already been retrieved.&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span&gt;&lt;div style=&#34;background-color: white; text-align: left;&#34;&gt;&lt;span style=&#34;background-color: white;&#34;&gt;&lt;span style=&#34;font-family: Menlo, Monaco, Courier New, Courier, monospace;&#34;&gt;&lt;span style=&#34;font-size: 15.75px; letter-spacing: -0.063px;&#34;&gt;The following tutorial goes through the process of creating the new script from start to finish.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;span&gt;&lt;span style=&#34;letter-spacing: -0.063px;&#34;&gt;&lt;span style=&#34;background-color: white;&#34;&gt;Retrieving the data, saving to disk and running this script many times in parallel allows for a decently high throughput. The bottle neck was no longer MySQL and the single Python for loop, but the network bandwidth of the server hosting the 2 million files and the RAM/CPU of the computer I was making the requests from.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;If you&#39;re creative, this method could be applied a number of ways to projects that require a high number of &#34;download + insert&#34; actions in one shot.&lt;br/&gt;&lt;br/&gt;&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;b&gt;Overview&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&#34;text-align: left;&#34;&gt;&lt;ol style=&#34;text-align: left;&#34;&gt;&lt;li&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Pull each of the 2 million URLs, save the URL to a single text file with each URL as a new line. &lt;br/&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Split the list of 2 million URLs into grouped text files of 250 lines each (2 million URLs / 250 URLs = 8,000 groups). We&#39;ll call these the &#34;group files&#34;.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Create a &#34;queue&#34; table in MySQL to store the grouped file filenames.&lt;br/&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Create a Python script to query a list of URLs in a &lt;i&gt;single&lt;/i&gt; group file, saving the contents of each request to disk.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Track the status of each grouped file in MySQL.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Randomize group file queuing to avoid collisions.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Run as many of the retriever scripts as your hardware can handle.&lt;br/&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Combined the output files.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Upload your 2 million results directly to MySQL using &lt;span style=&#34;background-color: #eeeeee;&#34;&gt;LOAD DATA INFILE&lt;/span&gt;&lt;span style=&#34;background-color: white; letter-spacing: -0.063px;&#34;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Tutorial&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Pull each of the 2 million URLs which point to the 2 million text files and save the &lt;i&gt;URLs&lt;/i&gt; to a single text file. I&#39;m not saving the file itself just yet, just the URL of the text file.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br/&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Here is the command to pull the filenames located in the remote directory:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;color: #444444; font-family: courier;&#34;&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; white-space: pre; width: 513px;&#34;&gt;curl -v -u &#34;user:password&#34; https://domain.com/data/crime_data/split/ | grep -o &#39;href=&#34;file*.*&#34;&amp;gt;&#39; | sed &#39;s/href=&#34;//;s/\/&#34;&amp;gt;//;s/\.[^.]*$//;s/\.txt.*/.txt/ &amp;gt; filenames.txt&lt;/pre&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;###&lt;br/&gt;Explanation&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: #444444; line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;color: black; font-family: courier; white-space: normal;&#34;&gt;curl &lt;/span&gt;&lt;span style=&#34;color: black; font-family: courier; white-space: normal;&#34;&gt;-v &lt;/span&gt;&lt;span style=&#34;color: black; font-family: courier; white-space: normal;&#34;&gt;-u &lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Curl verbose (-v) with a username and password (u).&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: #444444; line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;color: black; font-family: courier; white-space: normal;&#34;&gt;&#34;user:password&#34; &lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;The username and password&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: #444444; line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;https://domain.com/data/crime_data/split/&lt;span style=&#34;color: black; white-space: normal;&#34;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Destination of the web directory containing the 2 million files.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: #444444; line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;color: black; font-family: courier; white-space: normal;&#34;&gt;grep -o &#39;href=&#34;file*.*&#34;&amp;gt;&#39;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Grep the page contents for the filename links, print  only  the  matched (-o)&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;. I happen to know each filename starts with the word &#34;file&#34; in this case.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: #444444; line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;color: black; font-family: courier; white-space: normal;&#34;&gt;sed &#39;s/href=&#34;//;s/\/&#34;&amp;gt;//;s/\.[^.]*$//;s/\.txt.*/.txt/&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Use sed to remove the unwanted HTML elements. I happen to know each file is a .txt file here.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: #444444; line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;color: black; font-family: courier; white-space: normal;&#34;&gt;&amp;gt; filenames.txt&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Output to filenames.txt&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;####&lt;br/&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Count the lines in this file to check that the number of filenames is as expected.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;$ wc -l filenames.txt&lt;br/&gt;2230144 filenames.txt&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Split &lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;filenames.txt into ~8,000 files of 250 lines each.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: #444444; line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;color: black; font-family: courier; white-space: normal;&#34;&gt;$ mkdir groups&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;$ split -d -a5 -l 250 --additional-suffix=.txt filenames.txt ./groups/&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;###&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Explanation&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;split -d -a5 &lt;/span&gt;--additional-suffix=.txt&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;color: #181818; margin-left: 8px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Use numeric suffixes starting at 0 (-d) with a 5 digit suffix (-a5), 
250 lines (-l) and an additional suffix to file names (--additional-suffix=.txt)&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;###&lt;br/&gt;&lt;br/&gt;Check the group directory.&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;$ ls ./groups/head -20&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span&gt;&lt;span style=&#34;font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&#34;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style=&#34;font-family: Arial; font-size: 11pt; font-variant-east-asian: normal; font-variant-numeric: normal; vertical-align: baseline; white-space: pre-wrap;&#34;&gt;&lt;span style=&#34;border: none; display: inline-block; height: 156px; overflow: hidden; width: 539px;&#34;&gt;&lt;img height=&#34;156&#34; src=&#34;https://stephenkrings.com/images/gigashock/6000-inserts-per-minute-without-high/image-05-c4eaf5c51d.png&#34; style=&#34;margin-left: 0px; margin-top: 0px;&#34; width=&#34;539&#34;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;The group directory&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt; contains a list of the &lt;i&gt;group&lt;/i&gt; filenames.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;If you open one of the group files, it will contain a list of 250 filenames.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;$ &lt;/span&gt;head -20 ./groups/00000.txt&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;img height=&#34;138&#34; src=&#34;https://stephenkrings.com/images/gigashock/6000-inserts-per-minute-without-high/image-06-5d2331c385.png&#34; style=&#34;font-family: Arial; font-size: 11pt; margin-left: 0px; margin-top: 0px; white-space: pre-wrap;&#34; width=&#34;447&#34;/&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Login to MySQL to create the queue table to keep track of the groups.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;div style=&#34;font-family: courier; white-space: normal;&#34;&gt;mysql&amp;gt; create database queue;&lt;/div&gt;&lt;div style=&#34;font-family: courier; white-space: normal;&#34;&gt;Query OK, 1 row affected (0.00 sec)&lt;/div&gt;&lt;div style=&#34;font-family: courier; white-space: normal;&#34;&gt;&lt;br/&gt;&lt;/div&gt;&lt;div style=&#34;font-family: courier; white-space: normal;&#34;&gt;mysql&amp;gt; use queue;&lt;/div&gt;&lt;div style=&#34;font-family: courier; white-space: normal;&#34;&gt;Database changed&lt;/div&gt;&lt;div style=&#34;font-family: courier; white-space: normal;&#34;&gt;&lt;br/&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;mysql&amp;gt; &lt;/span&gt;CREATE TABLE group_name(&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;filename VARCHAR(100) NOT NULL,&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;status VARCHAR(100) NOT NULL DEFAULT &#39;0&#39;&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;mysql&amp;gt; exit&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;Bye&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Export filenames from the group directory to a .csv file&lt;br/&gt;&lt;/span&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;$ cd ..&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;$ find ./groups -type f -printf &#34;%f\n&#34;&amp;gt; groupnames.csv&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;background-color: white; font-family: courier;&#34;&gt;Enable local-infile in MySQL&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;[mysqld]&lt;br/&gt;local-infile&lt;br/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;$ sudo service mysql restart&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;background-color: white; font-family: courier;&#34;&gt;Upload groupnames.csv to MySQL&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;$ mysql --host=127.0.0.1 --local-infile=1 -D queue -e &#34;LOAD DATA LOCAL INFILE &#39;./groupnames.csv&#39; INTO TABLE group_name FIELDS TERMINATED BY &#39;,&#39; (filename)&#34; -u user -p&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;div style=&#34;font-family: courier; white-space: normal;&#34;&gt;&lt;div&gt;mysql&amp;gt; select * from group_name LIMIT 10;&lt;/div&gt;&lt;div&gt;+-----------+--------+&lt;/div&gt;&lt;div&gt;| filename  | status |&lt;/div&gt;&lt;div&gt;+-----------+--------+&lt;/div&gt;&lt;div&gt;| 05818.txt | 0      |&lt;/div&gt;&lt;div&gt;| 04080.txt | 0      |&lt;/div&gt;&lt;div&gt;| 02782.txt | 0      |&lt;/div&gt;&lt;div&gt;| 01491.txt | 0      |&lt;/div&gt;&lt;div&gt;| 03464.txt | 0      |&lt;/div&gt;&lt;div&gt;| 05001.txt | 0      |&lt;/div&gt;&lt;div&gt;| 00838.txt | 0      |&lt;/div&gt;&lt;div&gt;| 02670.txt | 0      |&lt;/div&gt;&lt;div&gt;| 08744.txt | 0      |&lt;/div&gt;&lt;div&gt;| 02332.txt | 0      |&lt;/div&gt;&lt;div&gt;+-----------+--------+&lt;/div&gt;&lt;div&gt;10 rows in set (0.00 sec)&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;mysql&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;mysql&amp;gt; select count(*) from group_name;
+----------+
| count(*) |
+----------+
|     8921 |
+----------+
1 row in set (0.03 sec)
&lt;p&gt;mysql&amp;gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Now I have a list of the &lt;/span&gt;&lt;span style=&#34;background-color: white; font-family: courier;&#34;&gt;8,921 &lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&amp;ldquo;grouped&amp;rdquo; &lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;filename&lt;span style=&#34;background-color: white;&#34;&gt;s&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;background-color: white;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt; &lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;in MySQL. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br/&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;The Python below script will iterate through each of the 2 million files, one group at a time and extract the information I need from each of the 2 million text files and save this information on disk. Once the script is done, the newly sorted 2 million lined file can be uploaded to MySQL using &lt;/span&gt;&lt;span style=&#34;background-color: #eeeeee; font-family: courier;&#34;&gt;LOAD DATA INFILE&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Edit /etc/mysql/mysql.conf.d to increase the number of connections to your MySQL database.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Add the following line to &lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;mysql.conf.d:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;$ &lt;/span&gt;max_connections = 100000&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Create an output directory for the output files.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;$ &lt;/span&gt;mkdir /home/ubuntu/scrape/output&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;This is the Python script for retrieving the 2 million files:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br/&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;a href=&#34;https://github.com/kringz/file_retriever/blob/main/pull.py&#34;&gt;&lt;a href=&#34;https://github.com/kringz/file_retriever/blob/main/pull.py&#34;&gt;https://github.com/kringz/file_retriever/blob/main/pull.py&lt;/a&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br/&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;You can run the script many times at once with the following bash script. This is a quick and dirty method for doing so. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;$ &lt;/span&gt;vim run_many.sh&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;div style=&#39;font-family: &#34;Times New Roman&#34;; white-space: normal;&#39;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;div&gt;#!/bin/sh&lt;/div&gt;&lt;div&gt;python pull.py &amp;amp; disown&lt;/div&gt;&lt;div&gt;sleep 2&lt;/div&gt;&lt;div&gt;python pull.py &amp;amp; disown&lt;/div&gt;&lt;div&gt;sleep 2&lt;/div&gt;&lt;div&gt;python pull.py &amp;amp; disown&lt;/div&gt;&lt;div&gt;python pull.py &amp;amp; disown&lt;/div&gt;&lt;div&gt;python pull.py &amp;amp; disown&lt;/div&gt;&lt;div&gt;python pull.py &amp;amp; disown&lt;/div&gt;&lt;div&gt;python pull.py &amp;amp; disown&lt;/div&gt;&lt;div&gt;python pull.py &amp;amp; disown&lt;/div&gt;&lt;div&gt;python pull.py &amp;amp; disown&lt;/div&gt;&lt;div&gt;python pull.py &amp;amp; disown&lt;/div&gt;&lt;div&gt;python pull.py &amp;amp; disown&lt;/div&gt;&lt;div&gt;python pull.py &amp;amp; disown&lt;/div&gt;&lt;div&gt;python pull.py &amp;amp; disown&lt;/div&gt;&lt;div&gt;&amp;hellip;&lt;br/&gt;&amp;hellip;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;background-color: white; font-family: courier;&#34;&gt;Add &amp;ldquo;&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;background-color: white;&#34;&gt;python pull.py &amp;amp; disown&amp;rdquo; to&lt;/span&gt;&lt;span style=&#34;background-color: white;&#34;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;background-color: white; font-family: courier;&#34;&gt;run_many.s&lt;/span&gt;&lt;span style=&#34;background-color: white;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;h&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt; &lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;as a&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;background-color: white; font-family: courier;&#34;&gt; new line as many times as you want&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span&gt;; up to &lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;8,921 times (as many grouped files that exist). The idea here is that this Python script runs on one &amp;ldquo;group&amp;rdquo; at a time.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;background-color: white;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;background-color: white;&#34;&gt;&lt;b&gt;Run it&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; width: 513px;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;span style=&#34;white-space: normal;&#34;&gt;$ &lt;/span&gt;bash_many.sh&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;background-color: white; font-family: courier;&#34;&gt;I ran&lt;/span&gt;&lt;span style=&#34;background-color: white;&#34;&gt;&lt;span style=&#34;font-family: courier;&#34;&gt; 1,200 pull.py scripts at once and achieved a retrieval rate of about 10,000 files per minute. In about 3 hours, I had gone through each of the 2 million text files and could upload the sorted data I needed to MySQL using &lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;background-color: #eeeeee; font-family: courier;&#34;&gt;LOAD DATA INFILE&lt;/span&gt;&lt;span style=&#34;background-color: white; font-family: courier;&#34;&gt;, which was quite fast:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;background-color: white; font-family: courier;&#34;&gt;&lt;div style=&#34;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); line-height: 14px; overflow: auto; padding: 0px; text-align: left; width: 513px;&#34;&gt;$ mysql &amp;ndash;host=localhost &amp;ndash;local-infile=1 -D queue -e &amp;ldquo;LOAD DATA LOCAL INFILE &amp;lsquo;./merged.csv&amp;rsquo; INTO TABLE group_name FIELDS TERMINATED BY &amp;lsquo;,&amp;rsquo; (filename)&amp;rdquo; -u user -p&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>When MySQL is Slow: Replacing MySQL with PrestoDB 0.246</title>
      <link>https://stephenkrings.com/posts/mysql-is-slow-replacing-mysql-with/</link>
      <pubDate>Wed, 03 Feb 2021 18:55:00 -0800</pubDate>
      <guid>https://stephenkrings.com/posts/mysql-is-slow-replacing-mysql-with/</guid>
      <description>&lt;p&gt;&lt;strong&gt;from my archived blog &lt;a href=&#34;http://blog.gigashock.com/&#34;&gt;blog.gigashock.com&lt;/a&gt;. reposted here.&lt;/strong&gt;&lt;/p&gt;
&lt;p style=&#34;text-align: center;&#34;&gt;&lt;img height=&#34;312&#34; src=&#34;https://stephenkrings.com/images/gigashock/mysql-is-slow-replacing-mysql-with/image-01-a15ee1ad91.png&#34; style=&#39;color: #37474f; font-family: &#34;Courier New&#34;; font-size: 10pt; margin-left: 0px; margin-top: 0px; white-space: pre-wrap;&#39; width=&#34;624&#34;/&gt;&lt;/p&gt;&lt;p style=&#34;text-align: left;&#34;&gt;&lt;a href=&#34;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnX0sHxzSVn8NwZP-ZddX74MZlD-faXTfdXWEMivi8er7isY6Snjmwk4LRTJ-IDkfxJU21OgC2FAbR0hVALINXq9Trm78kaNZ_p5Edzhczs-AvtLEdVK3DeBh2iwgGnXEtCidOgxex12Q/s159/stephen_profile_blogger.png&#34; style=&#34;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; white-space: pre-wrap;&#34;&gt;&lt;img height=&#34;168&#34; src=&#34;https://stephenkrings.com/images/gigashock/mysql-is-slow-replacing-mysql-with/image-02-044efb2c3d.png&#34; width=&#34;168&#34;/&gt;&lt;/a&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;By &lt;/span&gt;&lt;a href=&#34;https://www.linkedin.com/in/stephenkrings/&#34; style=&#34;font-family: courier;&#34; target=&#34;_blank&#34;&gt;Stephen Krings&lt;/a&gt;&lt;/p&gt;&lt;div&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;p style=&#34;background-color: white; text-align: center;&#34;&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;Former Security Operations Engineer at&lt;/span&gt;&lt;span style=&#34;font-family: courier;&#34;&gt; &lt;span style=&#34;color: black;&#34;&gt;&lt;a href=&#34;https://www.cloudflare.com/&#34; target=&#34;_blank&#34;&gt;Cloudflare, Inc&lt;/a&gt;&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;a href=&#34;http://github.com/kringz&#34; target=&#34;_blank&#34;&gt;github.com/kringz&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&#34;font-family: courier;&#34;&gt;&lt;a href=&#34;http://twitter.com/stephenkrings&#34;&gt;twitter.com/stephenkrings&lt;/a&gt;&lt;br/&gt;email: stephen &amp;lt;at&amp;gt; gigashock *dot* com&lt;br/&gt;&lt;br/&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;p style=&#34;font-family: courier; line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt; text-align: center;&#34;&gt;&lt;span style=&#34;font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: 700; vertical-align: baseline; white-space: pre-wrap;&#34;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
