Thursday, October 17, 2024

General tips you would give to make my SQL queries and databases better and faster

You should try, if you can, to avoid expressions in Selects, such as SELECT ColumnA +
ColumnB, etc. The query optimizer of the database, the portion of the DBMS that determines the best way to get the required data out of the database itself, handles expressions in such a way that would normally require more time to retrieve the data than if columns were normally selected, and the expression itself handled programmatically.
Minimize the number of columns included in a Group By clause.
If you are using a join, try to have the columns joined on (from both tables) indexed.
When in doubt, index.
Unless doing multiple counts or a complex query, use COUNT(*) (the number of rows
generated by the query) rather than COUNT(Column_Name)