In the join statement you showed us, you are transforming the datetime (into a plain date) in order to compare it. That means that the database engine will have to examine every *single* record in the table to see if they meet the criteria you're after. Even if you have an index on ins_date
, the engine will not be able to use it to find the records you're after.
See if you can re-craft the query to use the columns in their native
form (i.e. without any transformation applied to them). If you have to apply some kind of transformation to a column in order to do a join or filter, try to do it only to the tiniest table in that join, to reduce the number of records that have to be retrieved and transformed.
If you can, and this is a query that runs more than only occasionally, see if you can redefine the columns you are using to DATE rather than DATETIME types. If you need the time portion of the DATETIME value in your application(s), then see if you can maintain a ghost DATE column with only the DATE portion of that DateTime value (this can be maintained by the insert queries, or by a trigger).