I have a database with 300,000,000 records,
To insert new records, I want to check whether the record is already in the database or not,
I use the following query to confirm:
SELECT student_code FROM public.student_tbl WHERE class_type='high_school' AND class_register='true' AND (student_code='F40101197X0' OR student_code='F40101197X1' OR student_code='F40101197X2'); It will take 2 minutes to complete, it takes quite a while.
Therefore, I want to save the time to check data is already in the database or not by using the following query:
CREATE INDEX student_tbl_class_register_index ON public.student_tbl(class_register) WHERE class_register IS TRUE; Is it okay with the CREATE INDEX statement above?
Or how can I do well in this case, please tell me!
Any hint will be great. Thanks!
没有评论:
发表评论