Checking for a table's existence from a Python connection. (mapi ? sql?)
Hi, all. I’m trying to add a MonetDB interface to VoltTron, a Python based server for building and energy management systems. To that end I have to be able to use some of the mclient commands from it, for example, to check if a table exists (\d ), from Python. IIUC, monetdb.mapi.Connection objects should enable me to do that, but I have no idea how. A second question is about performance. The existing databse schema for this product looks like this in MonetDB: CREATE TABLE "voc"."data_test" ( "ts" TIMESTAMP(3) NOT NULL, "topic_id" INTEGER NOT NULL, "value_string" CHARACTER LARGE OBJECT NOT NULL, CONSTRAINT "data_test_topic_id_ts_unique" UNIQUE ("topic_id", "ts") ); There’s a time stamp and topic ID, and SELECT queries are almost always for a narrow range in time, and a small set of topic IDs (usually a set of one). The “value_string” is there because values in the topics can range in type, but are almost always floats. Can I expect MonetDB’s performance to be good For this use case? Or should I force the value_string to a float?
Hello Omri, Please see the answers inline Omri Schwarz @ 2017-03-09 20:25 GMT:
Hi, all.
I’m trying to add a MonetDB interface to VoltTron, a Python based server for building and energy management systems.
To that end I have to be able to use some of the mclient commands from it, for example, to check if a table exists (\d ), from Python. IIUC, monetdb.mapi.Connection objects should enable me to do that, but I have no idea how.
As far as I know the commands starting with the '\' character are specific to mclient, so you are not going to be able to use them from python. You can however test for the existence of any table using standard SQL to query the SQL catalog of MonetDB. Take a look here: https://monetdb.org/Documentation/SystemCatalog
A second question is about performance. The existing databse schema for this product looks like this in MonetDB:
CREATE TABLE "voc"."data_test" ( "ts" TIMESTAMP(3) NOT NULL, "topic_id" INTEGER NOT NULL, "value_string" CHARACTER LARGE OBJECT NOT NULL, CONSTRAINT "data_test_topic_id_ts_unique" UNIQUE ("topic_id", "ts") );
There’s a time stamp and topic ID, and SELECT queries are almost always for a narrow range in time, and a small set of topic IDs (usually a set of one). The “value_string” is there because values in the topics can range in type, but are almost always floats. Can I expect MonetDB’s performance to be good For this use case? Or should I force the value_string to a float?
If I understand correctly your question, the query involves only the ts and the topic_id columns. If so, the type of any other column should not affect the performance of your query. Best regards, Panos.
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
participants (2)
-
Omri Schwarz
-
Panagiotis Koutsourakis