I am new to indexing and running into an issue where Postgresql keeps saying there's an error with my code.
Do I need to add the foreign key on the bookings table that references the primary key of the members table.
How can I implement indexing if my SQL table structure is as follows and I have a JOIN query with WHERE clause using joindate
SELECT *
FROM bookings b
JOIN members m ON m.memid = b.memid WHERE joindate > '2012-08-01';
bookings members
--------- ----------
PK: bookid PK: memid
facid surname
memid firstname
starttime address
slots joindate
recommendedby
My attempted query
CREATE JOIN INDEX join_memid_index FOR members JOIN bookings ON bookings.memid = members.memid
This is the error I got when I run above query
ERROR: syntax error at or near "JOIN"
LINE 1: CREATE JOIN INDEX join_memid_index FOR members JOIN bookings...
^
SQL state: 42601
Character: 8
CREATE INDEX, notCREATE JOIN INDEX. - Gordon Linoff