AllegroGraph memoryLimit query option - configuration

Where can I set AllegroGraph's memoryLimit query option that is mentioned here?
I am using AllegroGraph 4.9 and keep getting QUERY_MEMORY_LIMIT_REACHED errors when I execute one of my SPARQL queries via WebView.
The log says:
Query has reached memory limit of 4,294,967,296 when requesting 1,089,870,432 additional bytes.
<LISP query plan(?) goes here>
Consider restructuring your query or increasing the value of the :memoryLimit query option.
I will try to improve my query, but I would like to know where that memoryLimitoption lives, too.

AllegroGraph lets you specify several configuration options either in the configuration file or in each specific query. To specify an option in the query, AllegroGraph extends the PREFIX syntax. For example, to alter the memory limit, you would pre-pend:
PREFIX franzOption_memoryLimit: <franz:8g>
It's not common to need to do this so if you can include more details on the query, we can help diagnose and improve things. Another useful option is to log the query:
PREFIX franzOption_logQuery: <franz:yes>
Please contact AllegroGraph support at support#franz.com for more help.

Related

error while fetching rows in R

I want to fetch some data from my SQL server in R. The way I'm doing this is,
rs=dbSendQuery(con,"myquery")
data=fetch(rs,n=-1)
this works perfectly for a small table. However, for a bigger table, the fetch command says,
Warning message:
In fetch(ms, n = -1) : error while fetching rows
The problem still remains even if I restrict my rows (n=10). So, I'm not sure if it's a timeout problem or what.
What might be the case?
data shows,
1] creator ratio
<0 rows> (or 0-length row.names)
There are couple of points I want to mention which can help OP in identifying and fixing problem.
1) Do not use fetch. Instead use dbFetch. The quote from R-help suggests as
fetch() is provided for compatibility with older DBI clients - for all
new code you are strongly encouraged to use dbFetch()
2) Execute your query from Query Editor in SQL Server Management Studio and check for performance. Fine tune tables used query for indexes. Once ready and happy try it from R
3) If query is selecting many columns then it would be good to first try selecting just one or two columns.
4) I hope you freeing resources and closing connection in later part of your code. It can be done like:
# Free all resources
dbClearResult(rs)
# Close connection
dbDisconnect(con)

Why did you sql query overcome hibernate query?

I want to know difference between Mysql Query and Hibernate Query. Anybody know give your Suggestion
There is a world of difference between the two. I will try my best to explain it to you.
For writing a MySQL query, you need to think in terms of tables, whereas for a Hibernate query, you need to think in terms of objects.
If you have MySQL queries embedded in your Java code, when you try to switch your database to a different one (say Oracle for example), your queries may not work anymore. This is because different db vendors have different syntax's that they need you to use to accomplish the same goal.
However, in the case of a Hibernate query, you will need to just change the appropriate property in the hibernate configuration file. Since you write queries in terms of objects, Hibernate will automatically generate the appropriate SQL it requires to work with the underlying db.
Also, one another major difference between the two (or between Hibernate and a specific db query language) is the way joins are done. We can use the dot operator in Hibernate Query Language (HQL) to access the properties of a component object without needing to explicitly specify a JOIN clause as we would in a specific query language.
Besides this, there are tons of differences between the two and in no way can all of them be summarized here.

Cheapest SQL Statement possible / Are there Client-Side SQL Statements?

Questions
What is/are the most cheapest SQL-Statment(s) (in terms of Processing Overhead/CPU Cycles).
Are there (this will most likely be DB-Client specific) any Statments that are evaluated directly by the client and even do not go to the database server?
The result doesn't matter, if an empty statement (which produces an SQL Error) is the cheapest OK, then this is good too. But I am more interested in non Error Responses.
Background:
I have an application that queries a lot of data from the DB. However I do not require this data. Sadly, I have no possibility to skip this query. But I have the possibility to change the SQL Query itself. So I am trying to find the cheapst SQL Statement to use, ideally it should not even go to the SQL Server and the SQL-Client Library should answer it. I will be using MySQL.
UPDATES (on comments):
Yes, it can be a No-Operation. It must be something I can pass as a regular SQL String to the mysql client library. Whatever that string could be, is the question. The goal is, that this Query then somehowreturns nothing, using the least Resources on the SQL Server as possible. But in idealcase the client itself will realize that this query doesnt even have to go to the server, like a version Check of the client library (OK I know this is no standard SQL then but maybe there is something I do not know about, a statement that will be "short circuited/answered" on the client itself).
Thanks very much!
DO 0
DO executes the expressions but does not return any results. In most respects, DO is shorthand for SELECT expr, ..., but has the advantage that it is slightly faster when you do not care about the result.

Default database for MySQL

Is there a way to allocate a default database to a specific user in MySQL so they don't need to specify the database name while making a query?
I think you need to revisit some concepts - as Lmwangi points out if you are connecting with mysql client then my.cnf can set it.
However, your use of the word query suggests that you are talking about connecting from some programming environment - in this case you will always need a connection object. To create connection object and in this case having default database to connect to will lead to no improvement (in terms of speed or simplicity). Efficiently managing your connection(s) might be interesting for you - but for this you should let us know exactly what is your environment.
If you use a database schema you don't need to specify the database name every time, but you need to select the database name.
The best thing to do would be to use a MySQL trigger on the connection. However, MySQL only accepts triggers for updates, deletes and inserts. A quick Google search yielded an interesting stored procedure alternative. Please
see MySQL Logon trigger.
When you assign the permissions to every user group, you can also specify, at the same file, several things for that group, for example the database that users group need to use.
You can do this with a specification file, depending on the language you are working with, as a simple variable. Later, you only have to look for that variable to know which database you need to work with. But, I repeat, it depends on the language. The specification file can be an XML, phpspecs file, or anything like this.

Embedding comments in MySQL statements

Does anyone know of a way to embed comments in MySQL statements? When I search for mysql and comments I get only ways to put comments in tables, etc
The idea, if I implement this the way my boss wants it, is to prepend the user id to the statement apparently so that when MySQL is analyzed later (via the binary log) we know who did what.
Example:
SELECT id
FROM customer
WHERE handle='JBH'
Would now show up as:
-- user:jwilkie
SELECT id
FROM customer
WHERE handle='JBH'
(or similar)
EDIT FOR CLARITY: The reason for this is that we have perl modules that are interfacing with MySQL and we are retrieving the user id by reading $ENV{USER} (which in this case is "jwilkie"). It is a situation where we have one MySQL user defined but multiple people running the perl mod.
Does anyone have experience with this? Many many thanks! Jane
Normally, comments are stripped before the SQL statement is recorded in the binary log. However, a nasty workaround is to pretend that ypur comment contains syntax for some future version of MySQL - eg. 9.99.99:
/*!99999 user:jwilkie */ insert into tbl values (yyy);
These comments will then be passed through into the binary log.
If you have control over the SQL queries being generated, then you should be able to embed comments in them programatically in your query builder.
Select queries don't go in the binary log, but the comments may make it into the slow query log, general query log, etc.
Here's a blog post from Percona that touches on the subject a bit, specifically in the context of mk-query-digest. It might help:
http://www.mysqlperformanceblog.com/2010/07/05/mk-query-digest-query-comments-and-the-query-cache/