| От | gar8@pitt.edu (Tony Reina) |
|---|---|
| Тема | Primary key order matters? |
| Дата | |
| Msg-id | a1688e61.0209110655.ee37154@posting.google.com обсуждение исходный текст |
| Список | pgsql-admin |
I've been tinkering with my database design over the last few months and today have found something significant that I wanted to share. It looks as though the order of the primary key index matters. I had originally had the order set the way I would typically think of the data if I were to look it up by hand (subject, arm, repetition). But then, I switched the order so that the field "repetition" was first. My queries sped up several orders of magnitude! (The cost went from something like 295,000 to 295). I think this is because there are many more repetitions than subjects. So at least for me, the primary key should be order so that the fields with more variance are listed first. Perhaps, this is known already to SQL gurus, but I hadn't come across it in reading about database optimization. -Tony
В списке pgsql-admin по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера