Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What your colleagues created are an Entity Attribute Value (EAV) store. I'll leave aside whether those are evil things or not.</p> <p>The short answer is: you cannot optimize your queries.</p> <p>The longer answer is: you might be able to toss in an (indexed) type field in the AV your table B, to make things slightly more efficient.</p> <p>Depending on what you store in it, a slightly related option might be to maintain extra typed fields therein using triggers, and indexing the latter as well. For instance, a trigger could maintain an <code>int</code> field that holds the integer value of fields marked as having a type of <code>int</code>.</p> <p>That said, don't count on a great performance boost with those solutions, since you'll still be doing lots of needless joins. And keep in mind that both of these tricks add overhead (extra disk space + time related to index maintenance).</p> <p>The correct answer is: an EAV store should only ever get used to store <em>meta</em> information.</p> <p>By meta, I mean stuff that you'll seldom use a where clause on, let alone a very selective one.</p> <p>In other words, identify the key fields that are frequently queried against, whether for where clauses, join clauses, order by clauses, etc. Shift them back into table A, and index them properly.</p> <p>While you're at it, consider moving stuff that is present in most/all rows from table A as well: each field that you move will save you space due to no longer needing that <code>name</code> field in table B, and you'll get appropriately typed data as a bonus.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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