~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-updates

« back to all changes in this revision

Viewing changes to src/test/regress/sql/bitmapops.sql

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-20 12:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090320120013-hogj7egc5mjncc5g
Tags: upstream-8.4~0cvs20090328
ImportĀ upstreamĀ versionĀ 8.4~0cvs20090328

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-- Test bitmap AND and OR
 
2
 
 
3
 
 
4
-- Generate enough data that we can test the lossy bitmaps.
 
5
 
 
6
-- There's 55 tuples per page in the table. 53 is just
 
7
-- below 55, so that an index scan with qual a = constant
 
8
-- will return at least one hit per page. 59 is just above
 
9
-- 55, so that an index scan with qual b = constant will return
 
10
-- hits on most but not all pages. 53 and 59 are prime, so that
 
11
-- there's a maximum number of a,b combinations in the table.
 
12
-- That allows us to test all the different combinations of
 
13
-- lossy and non-lossy pages with the minimum amount of data
 
14
 
 
15
CREATE TABLE bmscantest (a int, b int, t text);
 
16
 
 
17
INSERT INTO bmscantest 
 
18
  SELECT (r%53), (r%59), 'foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo'
 
19
  FROM generate_series(1,70000) r;
 
20
 
 
21
CREATE INDEX i_bmtest_a ON bmscantest(a);
 
22
CREATE INDEX i_bmtest_b ON bmscantest(b);
 
23
 
 
24
-- We want to use bitmapscans. With default settings, the planner currently
 
25
-- chooses a bitmap scan for the queries below anyway, but let's make sure.
 
26
set enable_indexscan=false;
 
27
set enable_seqscan=false;
 
28
 
 
29
-- Lower work_mem to trigger use of lossy bitmaps
 
30
set work_mem = 64;
 
31
 
 
32
 
 
33
-- Test bitmap-and.
 
34
SELECT count(*) FROM bmscantest WHERE a = 1 AND b = 1;
 
35
 
 
36
-- Test bitmap-or.
 
37
SELECT count(*) FROM bmscantest WHERE a = 1 OR b = 1;
 
38
 
 
39
 
 
40
-- clean up
 
41
DROP TABLE bmscantest;