Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Add a primary key which is auto incrementing and name it id.</p> <p>I wrote a script which takes all the words in <code>/etc/dict</code> and ran md5 over them, writing out their name and hash to create something like this:</p> <pre><code>"2af2fc92ed1ee8080d9ab015ab053074", "Windex's "bfa818f0cac66108daef757706e97a99", "Windhoek "88d0e322fb73a2e971bc982bd348c777", "Windows </code></pre> <p>My route of doing this was very hacky so I wont post my way of achieving it, but overall it was quite simple and just essentially was based around:</p> <pre><code>while read line do echo $line | md5sum | awk '{print $1}' done </code></pre> <p>So I created a database table:</p> <pre><code>CREATE TABLE whashes ( id int auto_increment primary key, hash varchar(32), word varchar(16) ); </code></pre> <p>And used:</p> <pre><code>INSERT INTO whashes (hash, word) VALUES </code></pre> <p>With the output of my script above. Running a test for speed.</p> <pre><code>SELECT * FROM `whashes` WHERE word LIKE "poop" LIMIT 0 , 30 </code></pre> <p>Runs in 0.0324 sec. This is with 100k words and should stay around that speed</p> <pre><code>SELECT * FROM `whashes` WHERE hash LIKE "b538baf8573b52b5bcfdd551fffa6e9d" LIMIT 0 , 30 </code></pre> <p>Runs in 0.0202 sec.</p> <p>From my understanding using an auto incrementing primary id integer key the computer is able keep a large amount of id's in cache and do somewhat of a binary search on those values. Without a key like this the database engine has to loop through each value checking it, compared to one check which reduces the amount needed to be checked by half each time. However, this explanation may be slightly incorrect however someone else may be able to explain further / correct me if I'm wrong. Just doing something as simple as this should give you a large improvement.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload