I have a join table that I want to index only for the table that is produced after the join. I have read a lot of what is out there, so I understand the index syntax CREATE INDEX my_index I cannot get my head around how you would create an index for a join table only. I just cannot figure out the syntax
Given the following tables (NOTE this is just an example):
CREATE TABLE books(
id INT,
title VARCHAR(50),
author_id INT
);
CREATE TABLE authors(
id INT,
name VARCHAR(50)
);
How would the syntax work out to index the following query? For the purposes of this project it might not be sensible for me to keep indexs of either books or authors as both tables will be updated and inserted into frequently and I understand (correct me if wrong) that indexes slow everything down when created on frequently edited data:
SELECT * FROM authors, books WHERE books.author_id = authors.id AND books.title LIKE '%Great%';
Thank you for your time.
create index on books like
Check Explain Tool if you query is optimized or not
for eg.