Hi,
I was reading to day how indexing works. And I was trying some query, for
example below one. What the range basically means (cost=0.28..8.30 ? I don’t
understand this.
———————————
arup@ror ~/part-time-projects/entrylvl (add_index_to_job_sources)$ rails db
psql (9.5.0)
Type "help" for help.
entrylvl_dev=# \d job_sources;
Table "public.job_sources"
Column | Type | Modifiers
---------------+-----------------------------+----------------------------------------------------------
id | bigint | not null default
nextval('job_sources_id_seq'::regclass)
job_id | bigint |
source | character varying |
job_source_id | character varying |
created_at | timestamp without time zone | not null
updated_at | timestamp without time zone | not null
Indexes:
"job_sources_pkey" PRIMARY KEY, btree (id)
"index_job_sources_on_source_and_job_source_id" UNIQUE, btree (source,
job_source_id)
"index_job_sources_on_job_id" btree (job_id)
Foreign-key constraints:
"fk_rails_f45da00eca" FOREIGN KEY (job_id) REFERENCES jobs(id)
entrylvl_dev=# explain select * from job_sources where job_source_id =
'p_1208b146c9eb8905' AND source = 'indeed';
QUERY PLAN
------------------------------------------------------------------------------------------------------------------
Index Scan using index_job_sources_on_source_and_job_source_id on job_sources
(cost=0.28..8.30 rows=1 width=58)
Index Cond: (((source)::text = 'indeed'::text) AND ((job_source_id)::text =
'p_1208b146c9eb8905'::text))
(2 rows)
entrylvl_dev=#
—————————
Thanks,
Arup