To build fast queries, you need to follow some best practices when modifying data.
- INSERT statement best practices:
- Always use column names in INSERT. To avoid confusion, it's best to specify column names in your INSERT statements. For example, the following query may work fine:
INSERT INTO tablename VALUES (1, 'testing', 100);
- The previous query may encounter an error if the column types change or another column is added, so it's better to use the following query instead:
INSERT INTO tablename (id, name, value) VALUES (1, 'testing', 100);
- Use small batches when running large INSERT, UPDATE, and DELETE statements. This will avoid issues with the INSERT, UPDATE, or DELETE queries blocking ...