Index Only Scans'den farklıdır
Örnek
Elimizde şöyle bir tablo olsun
postgres=# \d usersTable "public.users"Column | Type | Collation | Nullable | Default--------------+--------------------------------+-----------+----------+---------firstname | character varying(300) | | |lastname | character varying(300) | | |name | character varying(300) | | |createdat | timestamp(6) without time zone | | |emailaddress | character varying(300) | | |lockout | boolean | | |status | numeric(30,0) | | |lockout_date | timestamp(6) without time zone | | |Indexes:"users_at_idx_1" btree (lockout, status, createdat DESC NULLS LAST)
Burada 3 tane sütun birlikte bir indeksi oluşturuyor.. Select * ile sorgulayalım.
SELECT * FROM users WHERE lockout IN (true) AND status IN (3, 4) AND createdat IN ('2023-05-18 00:00:00', '2023-06-19 00:00:00');
Çıktı şöyle. Index kullanımı görülebilir.
Index Scan using users_at_idx_1 on public.users (cost=0.56..24879.59 rows=7255 width=72) (actual time=0.132..33.704 rows=3686 loops=1) Output: firstname, lastname, name, createdat, emailaddress, lockout, status, lockout_date Index Cond: ((users.lockout = true) AND (users.status = ANY ('{3,4}'::numeric[])) AND (users.createdat = ANY ('{"2023-05-18 00:00:00","2023-06-19 00:00:00"}'::timestamp without time zone[]))) Buffers: shared hit=48 read=3653 Planning: Buffers: shared hit=53 Planning Time: 0.584 ms Execution Time: 34.102 ms
Hiç yorum yok:
Yorum Gönder