Обсуждение: Port Bug Report: Strange choice of index, or no choice of index, for numeric keys
Port Bug Report: Strange choice of index, or no choice of index, for numeric keys
От
Unprivileged user
Дата:
============================================================================ POSTGRESQL BUG REPORT TEMPLATE ============================================================================ Your name : Philip Warner Your email address : pjw@rhyme.com.au Category : runtime: back-end: SQL Severity : non-critical Summary: Strange choice of index, or no choice of index, for numeric keys System Configuration -------------------- Operating System : Linux 2.0.35 PostgreSQL version : 6.4 Compiler used : gcc 2.7.2.1 Hardware: --------- Pentium, 80MB Linux Acheron 2.0.35 #8 Wed Aug 19 11:54:15 MEST 1998 i586 unknown Versions of other tools: ------------------------ -------------------------------------------------------------------------- Problem Description: -------------------- The query optimizer seems to not use indexes for indexes based on float data types, or for range queries based on integers.This seems stramge. -------------------------------------------------------------------------- Test Case: ---------- Create Table test(f1 float4, f2 int4); Create Unique Index test_ix1 on test(f1); Create Unique Index test_ix2 on test(f2); explain select * from test where f1 = 1.0; # This does not use an index, this may be OK since it's a float. explain select * from test where f2 = 1; #This uses an index, which is good. explain select * from test where f2 > 1 and f2 < 3; #This does not use an index, which is strange. -------------------------------------------------------------------------- Solution: --------- --------------------------------------------------------------------------