Skip to content

Commit f4d49f4

Browse files
committed
Update indexes with null values links
1 parent d42fced commit f4d49f4

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

postgresql_indexes/create_data.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ from generate_series(1, 1000000) as g (idx);
1111
select * from test order by id asc limit 100;
1212

1313
drop index concurrently if exists idx_ref_without_nulls;
14-
create index concurrently if not exists idx_ref_without_nulls on test (ref) where ref is not null;
14+
create index concurrently if not exists idx_ref_without_nulls on test (ref) where ref is not null;
+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
set search_path to public;
22

3-
explain (analyze, buffers) select * from test where ref in ('00000000000000000007', '00000000000000000008', '00000000000000000009') order by 1,2;
3+
explain (analyze, buffers)
4+
select * from test where ref in ('00000000000000000007', '00000000000000000008', '00000000000000000009')
5+
order by 1,2;

postgresql_indexes/readme.md

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
# Indexes with\without null values
2-
By default, PostgreSQL indexes null values and stores them to the generated index.
3-
In that way, we need to exclude null values explicitly from the index in order to decrease index size and increase write performance.
2+
3+
By default, PostgreSQL indexes the null values and stores them to the generated index.
4+
In that way, we need to exclude the null values explicitly from the index
5+
in order to decrease index size and increase write performance.
46

57
## Documentation
6-
- [Create index](https://postgrespro.ru/docs/postgrespro/11/sql-createindex)
7-
- [pg_stats](https://postgrespro.ru/docs/postgresql/11/view-pg-stats)
8+
9+
### RUS
10+
11+
- [create index](https://postgrespro.ru/docs/postgresql/16/sql-createindex)
12+
- [pg_stats](https://postgrespro.ru/docs/postgresql/16/view-pg-stats)
13+
14+
### ENG
15+
16+
- [create index](https://www.postgresql.org/docs/16/sql-createindex.html)
17+
- [pg_stats](https://www.postgresql.org/docs/16/view-pg-stats.html)
18+
-
819

920
## Example
21+
1022
| | tablename | indexname | num_rows | table_size | index_size | unique_idx |
1123
|---|-----------|-----------------------|----------|------------|------------|------------|
1224
| 1 | test | idx_ref_with_nulls | 1000000 | 46 MB | 55 MB | NO |

0 commit comments

Comments
 (0)