![]() ![]() Make your haystacks as small as possible before searching for your needlesĪrguably, we’re already getting into optimization here, but the goal should be to tell the database to scan the minimum number of values necessary to retrieve your results. In general, prioritize accuracy (does the query produce the intended results), and readability (can others easily understand and modify the code) before worrying about performance. ![]() And even then, only prioritize optimizing your query if it’s run frequently (like powering a popular dashboard), or if the query traverses a large number of rows. Avoid tuning your SQL query until you know your query returns the data you’re looking for. The standard warning against premature optimization applies here. Correctness, readability, then optimization: in that order Most of our discussion will concern SQL in general, but we’ll include some notes on features specific to Metabase that make writing SQL a breeze. This article covers some best practices for writing SQL queries for data analysts and data scientists. With Metabase, you don’t even have to use SQL.Organize your queries with Common Table Expressions (CTE).Avoid sorting where possible, especially in subqueries.Only use HAVING for filtering aggregates. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |