mirror of
https://github.com/not-kennethreitz/convore.json.git
synced 2026-06-21 15:40:58 +00:00
1 line
4.7 KiB
JSON
1 line
4.7 KiB
JSON
[{"user_id": 35994, "stars": [], "topic_id": 40449, "date_created": 1309044682.4533579, "message": "How many times have you written a model and then used the django-debug toolbar to look at the SQL and in the you end up with a queriy that just does not make sense. I think the best practice should to let django database ORM do its job, but I have some queries that it makes which are just not efficient! Basically Ive got some outer joins where I know you that the query does not need them and I can write it even with out inner join! Perhaps its becuase I did not write a good model in Django. Anyone else run into these type of issues? Is the solution to write a custom SQL or to just figure out what the heck is wrong with the model?", "group_id": 81, "id": 1486253}, {"user_id": 1126, "stars": [], "topic_id": 40449, "date_created": 1309045631.967582, "message": "that's usually a sign that you accidentally caused one to be triggered when the queryset evaluates", "group_id": 81, "id": 1486313}, {"user_id": 1126, "stars": [], "topic_id": 40449, "date_created": 1309045694.155138, "message": "(that's not the say that custom SQL isn't bad per-se, there's some occasions when chaining Q won't do the trick)", "group_id": 81, "id": 1486316}, {"user_id": 1126, "stars": [], "topic_id": 40449, "date_created": 1309045612.195013, "message": "the debug toolbar does a good job of giving you context/traces for queries, I would go through and try to understand _why_ it's doing a join when it shouldn't be to begin with", "group_id": 81, "id": 1486311}, {"user_id": 1126, "stars": [], "topic_id": 40449, "date_created": 1309045710.2149789, "message": "but for something simple like an extraneous join, I wouldn't resort to it just yet", "group_id": 81, "id": 1486318}, {"user_id": 35994, "stars": [], "topic_id": 40449, "date_created": 1309046446.366365, "message": "For example here are some specific thigns that confuse me. In this one query in the explain table all of the Select_types are simple. There are two tables that two not exist in my database so Im guessing they are temporary they have a humber T3 and T6?? There are two types eq_ref and index_merge. Is it the index_merge that is making for this complicated query?", "group_id": 81, "id": 1486362}, {"user_id": 35994, "stars": [], "topic_id": 40449, "date_created": 1309046273.1436851, "message": "I think my problem is more knowing how to read the django-toolbar for example knowing what the table means in the explained. The stacktrace is great to see which line is exectuing the query. But I think the only thing that can tell me how the query is really being generated is from the explain.", "group_id": 81, "id": 1486343}, {"user_id": 35994, "stars": [], "topic_id": 40449, "date_created": 1309050894.4296911, "message": "@pewpewarrows You know I think I maybe understand something here....If you read back the explain table I think the important things are the possible keys column, the key column, and the Extra Column. By doing a stare and compare what Ive noticed is that then I have multiple possible keys and the extra says that using index I get and inner join. When it the Extra Column reads something like Using Where, or Using File sort it ends up in an outer join. Now the next challenge is to understand why because all of the possible keys are indexed. Some of them are Foreign keys but I think django indexes them. This conversation is heading more to something apprpriate to stack over flow......", "group_id": 81, "id": 1486675}, {"user_id": 35994, "stars": [], "topic_id": 40449, "date_created": 1309053223.019408, "message": "@pewpewarrows I went in to MySQL (sorry no Postgres) and noticed that things that I thought were indexed do not seem to be. So I ran manage.py sqlindexes myapp and got a long list of things that need to be indexed. My question now is would it be better to add the db_indexes to the model that match what the output of sqlindexes gave me?", "group_id": 81, "id": 1486759}, {"user_id": 1126, "stars": [], "topic_id": 40449, "date_created": 1309052479.0853541, "message": "@desmondkaplan yeah without actual snippets (on pastebin or something) it'd be a bit difficult for me to try to follow along. stackoverflow's definitely a good place to start.", "group_id": 81, "id": 1486734}, {"user_id": 1126, "stars": [], "topic_id": 40449, "date_created": 1309052685.1248801, "message": "I wouldn't jump to explain immediately though, I usually only have to resort to that to see why a query is running slow/oddly", "group_id": 81, "id": 1486740}, {"user_id": 35994, "stars": [], "topic_id": 40449, "date_created": 1309059138.158905, "message": "ehh more ignorance on mypart I think sqlindexes only gives you the code that would be needed to create the indexes. They may have already been created", "group_id": 81, "id": 1487034}] |