Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>FULLTEXT indexes are really not as fast as you may think they are.</p> <p>Use a separate table to store your tags:</p> <pre><code>Table tags ---------- id integer PK tag varchar(20) Table tag_link -------------- tag_id integer foreign key references tag(id) content_id integer foreign key references content(id) /* this table has a PK consisting of tag_id + content_id */ Table content -------------- id integer PK ...... </code></pre> <p>You SELECT all content with tag x by using:</p> <pre><code>SELECT c.* FROM tags t INNER JOIN tag_link tl ON (t.id = tl.tag_id) INNER JOIN content c ON (c.id = tl.content_id) WHERE tag = 'test' ORDER BY tl.content_id DESC /*latest content first*/ LIMIT 10; </code></pre> <p>Because of the foreign key, all fields in tag_links are individually indexed.<br> The `WHERE tags = 'test' selects 1 (!) record.<br> Equi-joins this with 10,000 taglinks.<br> And Equi-joins <strong>that</strong> with 1 content record each (each tag_link only ever points to 1 content).<br> Because of the limit 10, MySQL will stop looking as soon as it has 10 items, so it really only looks at 10 tag_links records.<br> The content.id is autoincrementing, so higher numbers are very fast proxy for newer articles.</p> <p>In this case you <strong>never</strong> need to look for anything other than equality and you start out with 1 tag that you equi-join using integer keys (the fastest join possible). </p> <p>There are no if-thens-or-buts about it, this is the fastest way. </p> <p>Note that because there are at most a few 1000 tags, any search will be much faster than delving in the full contents table.</p> <p><strong>Finally</strong><br> CSV fields are a very bad idea, never use then in a database. </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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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