#!/usr/bin/perl -w use strict; use DBD::Pg; use Benchmark qw(:all); my $connect = "DBI:Pg:dbname=test"; my $index = "/home/dpavlin/pgestraier/data/casket"; my $dbh = DBI->connect($connect,"","") || die $DBI::errstr; sub search { my $def = pop; my $sth = $dbh->prepare("select * from pgest('$index',?,?,?,?,?) as ($def)") || die $dbh->errstr(); $sth->execute(@_) || die $sth->errstr(); my @arr; while (my $row = $sth->fetchrow_hashref() ) { push @arr, $row; } } timethese( 1000, { '0_seedcache' => sub { search("blade runner", undef, undef, undef, "{'\@id'}", 'id text'); }, '1_attr_1' => sub { search("blade runner", undef, undef, undef, "{'\@id'}", 'id text'); }, '2_attr_2' => sub { search("blade runner", undef, undef, undef, "{'\@id',\@title'}",'id text, title text'); }, '3_attr_3' => sub { search("blade runner", undef, undef, undef, "{'\@id',\@title','\@size'}",'id text, title text, size text'); }, '4_attr_4' => sub { search("blade runner", undef, undef, undef, "{'\@id',\@title','\@size','quote'}",'id text, title text, size text, quote text'); }, '5_attr_5' => sub { search("blade runner", undef, undef, undef, "{'\@id',\@title','\@size','quote','year'}",'id text, title text, size text, quote text, year text'); }, '5_attr_6' => sub { search("blade runner", undef, undef, undef, "{'\@id',\@title','\@size','quote','year',\@uri'}",'id text, title text, size text, quote text, year text, uri text'); }, '5_attr_6same' => sub { search("blade runner", undef, undef, undef, "{'\@id',\@id','\@id','\@id','\@id',\@id'}",'id1 text, id2 text, id3 text, id4 text, id5 text, id6 text'); }, });