mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-06 12:40:56 +08:00
Fixed index scan count
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
## 0.4.1 (unreleased)
|
||||||
|
|
||||||
|
- Fixed index scan count
|
||||||
|
|
||||||
## 0.4.0 (2023-01-11)
|
## 0.4.0 (2023-01-11)
|
||||||
|
|
||||||
If upgrading with Postgres < 13, see [this note](https://github.com/pgvector/pgvector#040).
|
If upgrading with Postgres < 13, see [this note](https://github.com/pgvector/pgvector#040).
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "access/relscan.h"
|
#include "access/relscan.h"
|
||||||
#include "ivfflat.h"
|
#include "ivfflat.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
|
#include "pgstat.h"
|
||||||
#include "storage/bufmgr.h"
|
#include "storage/bufmgr.h"
|
||||||
|
|
||||||
#include "catalog/pg_operator_d.h"
|
#include "catalog/pg_operator_d.h"
|
||||||
@@ -267,6 +268,9 @@ ivfflatgettuple(IndexScanDesc scan, ScanDirection dir)
|
|||||||
{
|
{
|
||||||
Datum value;
|
Datum value;
|
||||||
|
|
||||||
|
/* Count index scan for stats */
|
||||||
|
pgstat_count_index_scan(scan->indexRelation);
|
||||||
|
|
||||||
/* Safety check */
|
/* Safety check */
|
||||||
if (scan->orderByData == NULL)
|
if (scan->orderByData == NULL)
|
||||||
elog(ERROR, "cannot scan ivfflat index without order");
|
elog(ERROR, "cannot scan ivfflat index without order");
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use PostgresNode;
|
use PostgresNode;
|
||||||
use TestLib;
|
use TestLib;
|
||||||
use Test::More tests => 5;
|
use Test::More tests => 7;
|
||||||
|
|
||||||
my $dim = 768;
|
my $dim = 768;
|
||||||
|
|
||||||
@@ -32,10 +32,16 @@ $node->pgbench(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
sub idx_scan
|
||||||
|
{
|
||||||
|
$node->safe_psql("postgres", "SELECT idx_scan FROM pg_stat_user_indexes WHERE indexrelid = 'tst_v_idx'::regclass;");
|
||||||
|
}
|
||||||
|
|
||||||
my $expected = 10000 + 5 * 100 * 10;
|
my $expected = 10000 + 5 * 100 * 10;
|
||||||
|
|
||||||
my $count = $node->safe_psql("postgres", "SELECT COUNT(*) FROM tst;");
|
my $count = $node->safe_psql("postgres", "SELECT COUNT(*) FROM tst;");
|
||||||
is($count, $expected);
|
is($count, $expected);
|
||||||
|
is(idx_scan(), 0);
|
||||||
|
|
||||||
$count = $node->safe_psql("postgres", qq(
|
$count = $node->safe_psql("postgres", qq(
|
||||||
SET enable_seqscan = off;
|
SET enable_seqscan = off;
|
||||||
@@ -43,3 +49,4 @@ $count = $node->safe_psql("postgres", qq(
|
|||||||
SELECT COUNT(*) FROM (SELECT v FROM tst ORDER BY v <-> (SELECT v FROM tst LIMIT 1)) t;
|
SELECT COUNT(*) FROM (SELECT v FROM tst ORDER BY v <-> (SELECT v FROM tst LIMIT 1)) t;
|
||||||
));
|
));
|
||||||
is($count, $expected);
|
is($count, $expected);
|
||||||
|
is(idx_scan(), 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user