mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
f933766ba7
pgsql-hackers. pg_opclass now has a row for each opclass supported by each index AM, not a row for each opclass name. This allows pg_opclass to show directly whether an AM supports an opclass, and furthermore makes it possible to store additional information about an opclass that might be AM-dependent. pg_opclass and pg_amop now store "lossy" and "haskeytype" information that we previously expected the user to remember to provide in CREATE INDEX commands. Lossiness is no longer an index-level property, but is associated with the use of a particular operator in a particular index opclass. Along the way, IndexSupportInitialize now uses the syscaches to retrieve pg_amop and pg_amproc entries. I find this reduces backend launch time by about ten percent, at the cost of a couple more special cases in catcache.c's IndexScanOK. Initial work by Oleg Bartunov and Teodor Sigaev, further hacking by Tom Lane. initdb forced.
74 lines
1.5 KiB
Perl
Executable File
74 lines
1.5 KiB
Perl
Executable File
#!/usr/bin/perl
|
|
|
|
use strict;
|
|
print <<EOT;
|
|
create table message (
|
|
mid int not null,
|
|
sections int[]
|
|
);
|
|
create table message_section_map (
|
|
mid int not null,
|
|
sid int not null
|
|
);
|
|
|
|
EOT
|
|
|
|
open(MSG,">message.tmp") || die;
|
|
open(MAP,">message_section_map.tmp") || die;
|
|
|
|
srand( 1 );
|
|
#foreach my $i ( 1..1778 ) {
|
|
#foreach my $i ( 1..3443 ) {
|
|
#foreach my $i ( 1..5000 ) {
|
|
#foreach my $i ( 1..29362 ) {
|
|
#foreach my $i ( 1..33331 ) {
|
|
#foreach my $i ( 1..83268 ) {
|
|
foreach my $i ( 1..200000 ) {
|
|
my @sect;
|
|
if ( rand() < 0.7 ) {
|
|
$sect[0] = int( (rand()**4)*100 );
|
|
} else {
|
|
my %hash;
|
|
@sect = grep { $hash{$_}++; $hash{$_} <= 1 } map { int( (rand()**4)*100) } 0..( int(rand()*5) );
|
|
}
|
|
if ( $#sect < 0 || rand() < 0.1 ) {
|
|
print MSG "$i\t\\N\n";
|
|
} else {
|
|
print MSG "$i\t{".join(',',@sect)."}\n";
|
|
map { print MAP "$i\t$_\n" } @sect;
|
|
}
|
|
}
|
|
close MAP;
|
|
close MSG;
|
|
|
|
copytable('message');
|
|
copytable('message_section_map');
|
|
|
|
print <<EOT;
|
|
|
|
CREATE unique index message_key on message ( mid );
|
|
--CREATE unique index message_section_map_key1 on message_section_map ( mid, sid );
|
|
CREATE unique index message_section_map_key2 on message_section_map ( sid, mid );
|
|
CREATE INDEX message_rdtree_idx on message using gist ( sections gist__int_ops );
|
|
VACUUM ANALYZE;
|
|
|
|
select count(*) from message;
|
|
select count(*) from message_section_map;
|
|
|
|
|
|
|
|
EOT
|
|
|
|
|
|
unlink 'message.tmp', 'message_section_map.tmp';
|
|
|
|
sub copytable {
|
|
my $t = shift;
|
|
|
|
print "COPY $t from stdin;\n";
|
|
open( FFF, "$t.tmp") || die;
|
|
while(<FFF>) { print; }
|
|
close FFF;
|
|
print "\\.\n";
|
|
}
|