Overview of SQLite::VirtualTable::Pivot algorithm
  
   SELECT entity FROM pivot_table
       WHERE attribute_1 = value_1 and attribute_2 = value_2;
  
  becomes
  
   CREATE TEMPORARY TABLE temp1 AS
      SELECT distinct(entity) as entity
      FROM base_table
      WHERE name='attribute_1' AND value = 'value_1';
  
   CREATE TEMPORARY TABLE temp2 AS
      SELECT distinct(entity) as entity
      FROM base_table
      WHERE name='attribute_2' AND value = 'value_2';
  
   SELECT a.entity,a.attribute,a.value
      FROM base_table a
        INNER JOIN temp1 ON temp1.entity = a.entity
        INNER JOIN temp2 ON temp2.entity = a.entity
      ORDER BY a.entity
  
   Then, rows are pivoted one at a time as they are returned.
  
   (NB: temp tables are memory-only)