4 ms·
Here's his problem: -> Seq Scan on movie_person (cost=0.00..10117.01 rows=97 width=8) (actual time=2.540..59.933 rows=9 loops=1) Filter: (p
by wiredfool 14y ago
Here's his problem:
-> Seq Scan on movie_person (cost=0.00..10117.01 rows=97 width=8)
(actual time=2.540..59.933 rows=9 loops=1)
Filter: (person_id = 160)
If he had an index on movie_person, that would be a ~ 1ms index lookup, not a table scan. You can't do that sort of database layout without putting indexes on the M2M mapping table.
(edit, oh, yeah, it's right there in the parent post....)
- nierman 14y agoand you probably want to include these indices in any case to enforce that a given (user, movie) pair in the join table is unique (unless you want to track if a rating was changed and when, etc.) further, you might decide to cluster on the index or partition.
- wiredfool 14y agoYep. You'd probably wind up wanting two indexes, a unique one on user,movie and then possibly one on movie only, to speed lookups the other way.