When I debugging I notice that for the some first row for example 50 or 100 (for any runs was different) it’s okay and so fast but after some rows when code reach to the .first() take 2 or 3 seconds for each row to response.I don’t use order_by because I have just one object in my filtered_by_date variable.
this is my query for example:
SELECT "csvtojson_stock_csv"."id", "csvtojson_stock_csv"."ticker", "csvtojson_stock_csv"."date", "csvtojson_stock_csv"."open", "csvtojson_stock_csv"."high", "csvtojson_stock_csv"."low", "csvtojson_stock_csv"."close", "csvtojson_stock_csv"."vol", "csvtojson_stock_csv"."arzesh", "csvtojson_stock_csv"."tedad", "csvtojson_stock_csv"."diroz", "csvtojson_stock_csv"."shamsi", "csvtojson_stock_csv"."akharin", "csvtojson_stock_csv"."office" FROM "csvtojson_stock_csv" WHERE ("csvtojson_stock_csv"."ticker" = کرماشا AND "csvtojson_stock_csv"."date" = 2020-02-23)
and when run this query in phpmyadmin mysql I got this error:
SQL query:
SELECT "csvtojson_stock_csv"."id", "csvtojson_stock_csv"."ticker", "csvtojson_stock_csv"."date", "csvtojson_stock_csv"."open", "csvtojson_stock_csv"."high", "csvtojson_stock_csv"."low", "csvtojson_stock_csv"."close", "csvtojson_stock_csv"."vol", "csvtojson_stock_csv"."arzesh", "csvtojson_stock_csv"."tedad", "csvtojson_stock_csv"."diroz", "csvtojson_stock_csv"."shamsi", "csvtojson_stock_csv"."akharin", "csvtojson_stock_csv"."office" FROM "csvtojson_stock_csv" WHERE ("csvtojson_stock_csv"."ticker" = کرماشا AND "csvtojson_stock_csv"."date" = 2020-02-23) LIMIT 0, 25
MySQL said:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '."id", "csvtojson_stock_csv"."ticker", "csvtojson_stock_csv"."date", "csvtojs...' at line 1
Every csv can have 2000 rows less or more.
Primary key in setting of django is set to django.db.models.BigAutoField
We don’t have a default ordering in model.
All of this problem happened in mysql not in the sqlite.