MySQL Forums
Forum List  »  Connector/Node.js

Re: insert performance issue
Posted by: Rui Quelhas
Date: March 31, 2021 05:17AM

Hi Eric,

as mentioned in the documentation (https://dev.mysql.com/doc/dev/connector-nodejs/8.0/tutorial-Prepared_Statements.html) at the moment, the X DevAPI connector for Node.js (or any other X DevAPI/X Protocol implementation) does not support prepared statements for SQL statements (Session.sql() -> Mysqlx.Sql.StmtExecute) and CRUD inserts (Collection.add() and Table.insert() -> Mysqlx.Crud.Insert). Which, coincidentially, are exactly the APIs that would suite your needs.

This is a known limitation, but in any case, I suggest you submit an enhancement request using our public bug tracker (http://bugs.mysql.com/) using the "MySQL Connectors: Document Store: DevAPI" category.

With regards to performance, I've tested similar workloads to yours using the X DevAPI connector for Node.js and some other community drivers that use the classic protocol, and the results (while not using prepared statements) are similar. Maybe you can point me to an even more specific situation where that might not be the case.

Some other things that caught my eye. Due to the way that .bind() works with SQL statement parameters (ordinal and cumulative by nature), you cannot re-use the same statement instance ("command" in your case) to execute different queries. It will only use the values you provided in the first run and then will start to hit a "Too many arguments" error reported by the server.

This is more like a Node.js-specific behaviour (for instance, with the MySQL Shell that does not happen), so I would say it probably can be improved. Once again, I would suggest you submit a bug report using our public bug tracker, this time using the "Connector for Node.js" category.

Also, I'm not a schema design expert, but maybe using a traditional relational table to store logs, which I guess is what you want/need, and are kind of unstructured by nature, might not be the best approach. Have you considered or tried just saving them in JSON instead? Maybe it yields better results.

Hope it helps.


Thanks

Options: ReplyQuote


Subject
Written By
Posted
March 30, 2021 01:48PM
Re: insert performance issue
March 31, 2021 05:17AM
March 31, 2021 08:43AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.