VirtuosoException: SQ199

Hello everyone,
I stumbled upon an error about the size of the query:

virtuoso.jdbc4.VirtuosoException: SQ199: Maximum size (32767) of a code vector exceeded by 232041 bytes. Please split the code in smaller units.

In fact I have a query with a where clause that searches for 6000 ids and my only alternative that I wish to avoid is to split it in 2 queries.
Is there any way to avoid this?

Thanks,
Dora

@tkaraisku: The SQ199 32K max vector size is a known limit from some time ago, that cannot be worked around, other than by splitting the query as suggested.

What is the query being executed and is the a select or insert/update query ?

Did a bit digging and we have at least 3 select queries that have the same problem and the reason is that there is a case the where clause has 6000 ids :frowning: so I guess it is normal!
Just an idea of the query:

Summary
"SPARQL "
PREFIX torr: " + "<" + Ontology.ns + ">" + "\n"
PREFIX owl: " + "<" + Ontology.owlPrefix + ">" + "\n"
+ "PREFIX rdf: " + "<" + Ontology.rdfPrefix + ">" + "\n"
+ "PREFIX res: " + "<" + Ontology.instancePrefix + "Project/>" + "\n"
+ "SELECT DISTINCT ?projectId ?projectName ?projectProgram ?projectAcronym ?projectAbstract 
+ "(group_concat(DISTINCT ?firstTopicInfo; separator=\",\") as ?firstTopics) "
+ "(group_concat(DISTINCT ?highTopicInfo; separator=\",\") as ?highTopics) "
+ "from <" + Ontology.torrPrefix + ">" + "\n"
+ " WHERE {" + "\n"
+ "  ?project torr:projectId ?projectId ." + "\n"
+ "{" + "\n"
+ "{ SELECT ?project" + "\n"
+ " WHERE {" + "\n"
+ " VALUES ?project {res:222983 res:304963 res:241683 res:241955 res:223156 res:223445 res:600847 res:603121 res:242013 res:200234 res:304884 res:212281 res:223243 res:305207 res:304900 res:201804 res:278981 res:248294} }" + "\n"
+ "}
+ "
+ "			OPTIONAL {?project torr:projectName ?projectName }." + "\n"
+ "			OPTIONAL {?project torr:projectProgram ?projectProgram }." + "\n"
+ "			OPTIONAL {?project torr:projectAcronym ?projectAcronym }." + "\n"
+ "			OPTIONAL {?project torr:projectAbstract ?projectAbstract }." + "\n"
+ "			OPTIONAL { {?project torr:belongsToFirstTopic ?topic }." + "\n"
+ "						{?topic torr:topicFosId ?topicFosId }." + "\n"
+ "						{?topic torr:topicFosName ?topicFosName } }." + "\n"
+ "			OPTIONAL { {?project torr:belongsToHighTopic ?hightopic }.\n"
+ "					 {?hightopic torr:topicFosId ?hightopicFosId }.\n"
+ "					 {?hightopic torr:topicFosName ?hightopicFosName } }." + "\n"
+ "		 bind ( COALESCE(?hightopicFosName, \"\") As ?hightopicFosNameB)" + "\n"
+ "		 bind ( COALESCE(?hightopicFosId, \"\") As ?hightopicFosIdB)" + "\n"
+ "		 bind ( COALESCE(?topicFosName, \"\") As ?topicFosNameB)" + "\n"
+ "		 bind ( COALESCE(?topicFosId, \"\") As ?topicFosIdB)" + "\n"
+ "		 BIND (CONCAT('{ \"topicName\":', '\"', ?topicFosNameB, '\"', ', \"topicId\":', '\"', ?topicFosIdB, '\"',\" }\") AS ?firstTopicInfo)." + "\n"
+ "		 BIND (CONCAT('{ \"topicName\":', '\"', ?hightopicFosNameB, '\"', ', \"topicId\":', '\"', ?hightopicFosIdB, '\"',\" }\") AS ?highTopicInfo)" + "\n"
+ " } order by ?projectId";

@tkaraisku: Can you please provide the query compilation plans from executing this query.

Also, what is the Virtuoso version being used, is this with Virtuoso 7.2 open source or Virtuoso 8.3 commercial or both ?

I surely tested in Virtuoso 7.2, I think that I tested also in 8.3 and the result was the same. I can’t access the endpoints temporarily to confirm but as soon as are available again I will upload the plans.
I think we will implement the splitting to two queries at least because 6000 conditions is not really good idea at all, and to be honest I don’t know if at some point there will be more ids in that where.
Thanks Hugh :bowing_woman:t2: