G'day all - back at it.

So I built a new database with the new keys:

CREATE TABLE `responses` ( `respondent` smallint(5) unsigned NOT NULL +default '0', `response` smallint(5) unsigned NOT NULL default '0', PR +IMARY KEY (`respondent`,`response`), KEY `respondent` (`respondent`), + KEY `response` (`response`) ) TYPE=MyISAM
Populated it with my test data, and tried my search
SELECT COUNT(*) FROM theTable A JOIN theTable B ON (A.respondent = B.r +espondent) WHERE A.response = ? AND B.response = ?
And it's averaging 0.2 seconds this morning while the previous two-column version is averaging 0.13 sec and the far-fetched one-table-per-response db is averaging 0.09 sec.

Anyway, EXPLAIN on this query in this new database says

+-------+--------+-----------------------------+----------+---------+--------------------+------+--------------------------+
| table | type   | possible_keys               | key      | key_len | ref                | rows | Extra                    |
+-------+--------+-----------------------------+----------+---------+--------------------+------+--------------------------+
| A     | ref    | PRIMARY,respondent,response | response |       2 | const              | 3372 | Using where              |
| B     | eq_ref | PRIMARY,respondent,response | PRIMARY  |       4 | A.respondent,const |    1 | Using where; Using index |
+-------+--------+-----------------------------+----------+---------+--------------------+------+--------------------------+
I suppose next I'll try reversing the order of the index declarations, but is that really going to give me the boost to more than double speed?

Bit arrays and bit masks sound interesting, but Googling "bit array" & "bit mask" doesn't give me much. Any good reads on this somewhere?


In reply to Re: Does Search::InvertedIndex module live up to billing? by punch_card_don
in thread Does Search::InvertedIndex module live up to billing? by punch_card_don

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.