- Use Indexes for search or create index for commonly used column in WHERE conditions,
- Use Numeric fields to store Numeric values instead of Character datatypes.
- Replace UNION with UNION ALL where we dont have duplicate results. ( If duplicate data is not coming or if you dont want to remove duplicate data use this )
- Minimum use of DISTINCT keyword.
- Dont use select * FROM table_name.Instead use required columns only.
- Don’t use <> != as index will not be used for that and full table scan will be performed.
- Use EXISTS () instead of COUNT() to discover whether the table has a specific record.
- Use varchar / nvarchar instead of char because char takes extra spaces.
- Use LIMIT to preview query results.
Note:
- apache/superset#6998 If you are using a reserved keyword as a table name or something you may get an error, so just enclosed with double quotes.
"final" AS (
SELECT
vw.*,
TRIM(gc.first_name||' '||gc.last_name) AS "influencer_name"
FROM "vw" AS vw