Too many SQL variable

141 views
Skip to first unread message

HEMENDRA SINGH HADA

unread,
Feb 18, 2019, 7:37:07 AM2/18/19
to Django users
Hi All,
In my current project we are using sqlite3, When I am fetching data from sqlite3 db tables and counting the query-set length it is giving me error "Too many SQL query" when the length is more than 999. till 999 its working fine, Please suggest some quick fix for this,

Thanks in Advance

Sebastian Henschel

unread,
Feb 18, 2019, 7:51:33 AM2/18/19
to django...@googlegroups.com
Heya,

Am 18.02.19 um 10:52 schrieb HEMENDRA SINGH HADA:
The first questions which comes to my mind is, if you can rework your
queries?
Otherwise, i am not using sqlite3, but just found this, from
https://www.sqlite.org/limits.html :

---------

Maximum Number Of Host Parameters In A Single SQL Statement

A host parameter is a place-holder in an SQL statement that is filled in
using one of the sqlite3_bind_XXXX() interfaces. Many SQL programmers
are familiar with using a question mark ("?") as a host parameter.
SQLite also supports named host parameters prefaced by ":", "$", or "@"
and numbered host parameters of the form "?123".

Each host parameter in an SQLite statement is assigned a number. The
numbers normally begin with 1 and increase by one with each new
parameter. However, when the "?123" form is used, the host parameter
number is the number that follows the question mark.

SQLite allocates space to hold all host parameters between 1 and the
largest host parameter number used. Hence, an SQL statement that
contains a host parameter like ?1000000000 would require gigabytes of
storage. This could easily overwhelm the resources of the host machine.
To prevent excessive memory allocations, the maximum value of a host
parameter number is SQLITE_MAX_VARIABLE_NUMBER, which defaults to 999.

The maximum host parameter number can be lowered at run-time using the
sqlite3_limit(db,SQLITE_LIMIT_VARIABLE_NUMBER,size) interface.

-----------

Maybe you can put a call to this interface into a startup script somewhere?

Cheers,
--
Sebastian Henschel
Softwareentwickler Passivhaus Institut
http://passiv.de

signature.asc

HEMENDRA SINGH HADA

unread,
Feb 18, 2019, 10:14:58 AM2/18/19
to Django users
Hi,

Could you give me some quick fix, I am using django currently, or could be please suggest me how to take the parent table data with prefetch related filter. 

Thanks 
Reply all
Reply to author
Forward
0 new messages