![]() ![]() They discover "indexed views" and all is well until you start to have locking problems, so more hacks are needed. Which of the 10 table scans or index scans to tackle first? And how do you tackle it? ![]() The query plan for those beasts is intractable. But the problem with that is DB apathy + EF leads to some real performance problems as systems scale that grinds the application to a halt with SQL queries longer than dissertations, to which the developers need a quick hack to fix. Yes, EF queries are more readable to many developers who know C# well but don't want to get used to SQL. ![]() Just like Python and C# are equally readable to the respective cohorts that are used to programming in those languages. This is one way in which I mean SQL is bad. (Contast to the LINQ examples, or perhaps a shell pipline.) In a way, this is the substance of the original article. I need to basically read the entire statement to understand the parts. When I examine an SQL expression, and then visualize the relational operators involved, I find a very poor correspondence between the SQL expression and the relational algebra. We can ask: How well does SQL allow us to express an algorithm in relational terms? (Let's ignore that that SQL introduces some non-relational impurities that may have practical value - eg column order, row order, duplicate rows.) When we solve problems using relations, we benefit by thinking in terms of relations. So, we use relations to represent the data in the application domain, and use the operators of relational algebra to take relational inputs and produce relational outputs. The foundation theory is the relational model of data, and the use of operators from relational algebra. But in practice I find outer joins are more often used in these sort of situations.) ![]() (EDIT: I should probably call this "too many joins" instead, since it's not really specific to outer joins. If you don't know about this mistake, it's easy to get the wrong answer from aggregate functions like AVG or COUNT. Thinking imperatively about JOINs is also a helpful way of understanding a mistake I call "too many outer joins", which I wrote about here. You can even think about the joins "imperatively". Especially if your answer corresponds to an existing table, put that in the FROM, and then add whatever joins you need. I've trained a lot of non-developers (and new-developers) to use SQL, and one of my favorite tips is, "Start with FROM."Įven sooner than "start with FROM" is "What does each row of the result mean?" Is it a sale? A month of sales? A customer? If you can answer what you want, then it's usually easy to start there. However not sure if it can be done in that style?ĮDIT: Pretty sure this is working in the desired manner but will post here as still verifying that it has no bugs: def getProductByNameAndBrand(name, brand) doĪpi.Product |> (name: ^name) |> nuances aside, I agree with this and think it's helpful for anyone writing SQL. I prefer this kind of syntax: def getProductByNameAndBrand(name) doĪpi.Product |> (name: ^name) |> all (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6 (stdlib) lists.erl:1338: :lists.foreach/2 ** (CompileError) lib/api/repo.ex:278: undefined function p/0 This is throwing: = Compilation error on file lib/api/repo.ex = The record will always be singular because name and brand are a unique index: def getProductByNameAndBrand(name, brand) do I want to select a single record (the whole record) where the name is xxx and the brand is xxx. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |