Use statement batching when inserting resources
Use statement batching when inserting resources

We would previously do several SQL statements for insertion of a resource:

* insert its metadata
* N inserts for all of its parameters
* N inserts for all of its tags
* an insert to associate it with a catalog

...and we'd do that for all N resources in a catalog. That's a lot of queries.
Now, we use statement batching to queue up all the pending inserts on a
per-table basis. We then execute them in foreign-key-satisfying order:

* insert metadata for all resources in the catalog
* insert all resource parameters for all resources
* insert all resources tags for all resources
* associated all of the resources with the catalog

We do this all in a single round-trip to the database, saving a ton of wasted
time doing back-and-forth communication.

Note: this patch does not remove the query-per-resource penalty we pay when
determining if a resource exists. Even though that penalty remains, batched
inserts are still a pretty massive performance boost.

Signed-off-by: Deepak Giridharagopal <d11186354d1ef01ca06ae37d7e23e827da13e85f@puppetlabs.com>

highb/puppetdb,melissa/puppetdb,nfagerlund/puppetdb,grimradical/puppetdb,haus/puppetdb,cprice404/puppetdb,kbarber/puppetdb,waynr/puppetdb,johnduarte/puppetdb,highb/puppetdb,ajroetker/puppetdb,rbrw/puppetdb,puppetlabs/puppetdb,senior/puppetdb,waynr/puppetdb,haus/puppetdb,grimradical/puppetdb,mullr/puppetdb,jantman/puppetdb,johnduarte/puppetdb,ajroetker/puppetdb,ajroetker/puppetdb,wkalt/puppetdb,kbrezina/puppetdb,kbrezina/puppetdb,cprice404/puppetdb,rbrw/puppetdb,mullr/puppetdb,github/puppetlabs-puppetdb,mullr/puppetdb,github/puppetlabs-puppetdb,puppetlabs/puppetdb,waynr/puppetdb,cprice404/puppetdb,stahnma/puppetdb,shrug/puppetdb,highb/puppetdb,puppetlabs/puppetdb,melissa/puppetdb,rbrw/puppetdb,stahnma/puppetdb,kbarber/puppetdb,github/puppetlabs-puppetdb,wkalt/puppetdb,kbrezina/puppetdb,rbrw/puppetdb,shrug/puppetdb,senior/puppetdb,jantman/puppetdb,grimradical/puppetdb,waynr/puppetdb,kbarber/puppetdb,mullr/puppetdb,kbarber/puppetdb,stahnma/puppetdb,puppetlabs/puppetdb,senior/puppetdb,senior/puppetdb,haus/puppetdb,wkalt/puppetdb,puppetlabs/puppetdb,nfagerlund/puppetdb,ajroetker/puppetdb,kbrezina/puppetdb,highb/puppetdb,grimradical/puppetdb,mullr/puppetdb,melissa/puppetdb,wkalt/puppetdb,johnduarte/puppetdb,rbrw/puppetdb,johnduarte/puppetdb,shrug/puppetdb,shrug/puppetdb,nfagerlund/puppetdb,jantman/puppetdb