Example: in-memory acceleration of JSON

This example shows how you can use Informix® Warehouse Accelerator to accelerate data from JSON collections.

Before you begin

You must have installed and configured your MongoDB, Informix®, and Informix® Warehouse Accelerator environments.

Procedure

  1. From the MongoDB shell:
    1. Create two collections and comments.
      $ mongo demo_database
      MongoDB shell version: 2.4.9
      connecting to: demo_database
      mongos> db.comments.insert( [
         { uid:12345, pid:444, comment:"first" },
         { uid:12345, pid:888, comment:"second" },
         { uid:99999, pid:444, comment:"third" }
      ] )
      
    2. Create two users.
      mongos> db.users.insert( [
         { uid:12345, name:"john" },
         { uid:99999, name:"mia"  }
      ] )
      mongos> exit
  2. From Informix® DB-Access utility:
    1. Create views on JSON collections.
      $dbaccess demo_database -
      create view vcomments(uid,pid,comment) as select
        bson_value_int(data,'uid'),
        bson_value_int(data,'pid'),
        bson_value_varchar(data,'comment')
        from comments;
      create view vusers(uid,name) as select
        bson_value_int(data,'uid'),
        bson_value_varchar(data,'name')
        from users;
      
      set environment use_dwa 'probe cleanup';
      set environment use_dwa 'probe start';
      select {+ avoid_execute} * from vcomments c,vusers u where c.uid=u.uid;
      set environment use_dwa 'probe stop';
    2. Create the data mart by using query probing.
      execute procedure ifx_probe2mart('demo_database','noSQL_mart');
      execute function ifx_createmart('demo_dwa','noSQL_mart');
      execute function ifx_loadmart('demo_dwa','noSQL_mart','NONE');
      
    3. Run the accelerated query.
      set environment use_dwa 'accelerate on';
      select c.uid,name,comment from vcomments c,vusers u where c.uid=u.uid and
       pid=444;
      
      uid      12345
      name     john
      comment  first
      
      uid      99999
      name     mia
      comment  third