How to profile Doctrine MongoDB ODM? - doctrine

How can I profile Doctrine MongoDB ODM?
I would like to see all queries against database and the time of execution. Is there any way to configure a profiler? I would like to build a plugin that I would use it in ZFDebug toolbar.

The MongoDBODMModule for ZF2 may have some classes you could re-use to handle this problem in ZF1. If you're already using ZF2, then it is just a matter of installing the module and ZendDeveloperTools to have the toolbar.

MongoDB has its own profiler, check http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/

Related

What is the difference between ddl-auto and hbm2ddl.auto?

Every time I try to start "Spring Boot Dashboard" from VSCode I get an error while using the following command.
spring.jpa.hibernate.ddl-auto=update (Doesn't Work)
However, I managed to find this line here on stack overflow that made it work. The problem is I don't know the difference and how will it impact my production.
spring.jpa.hibernate.hbm2ddl.auto=update (Works)
Any sort of help would be more than appreciated.
From this Link
spring.jpa.hibernate.ddl-auto This is actually a shortcut for the "hibernate.hbm2ddl.auto" property.
Defaults to "create-drop" when using an embedded database and no schema manager was detected. Otherwise, defaults to "none".
From this Stackoverflow Link
In production, it's often highly recommended you use none or simply don't specify this property. That is because it's common practice for DBAs to review migration scripts for database changes, particularly if your database is shared across multiple services and applications.

How to use ligth4j to operate mysql

How to use ligth4j to operate mysql? The demo result from github seems incomplete. My project reference link is https://github.com/networknt/light-example-4j
Light4J doesn't implement anything to operate mysql, you could use directly the java libraries to do it (java.sql, javax.sql). If you need it, you could initialize a connection pool settings with StartupHookProvider and create your own MysqlStartupHookProvider
(review the mongoDb example: https://github.com/networknt/light-example-4j/blob/release/mongodb/src/main/java/com/networknt/database/db/MongoStartupHookProvider.java)

Embedded MongoDB instance?

I've been using MongoDB for a little tool that I'm building, but I have two problems that I don't know if I can "solve". Those problems are mainly related with having to start a MongoDB server (mongod).
The first is that I have to run two commands every time that I want to use it (mongod and my app's command) and the other is testing. For now, I'm using different collections for "production" and "test", but it would be better to have just an embedded / self-contained instance that I can start and drop whenever I want.
Is that possible? Or should I just use something else, like SQLite for that?
Thanks!
Another similar project is https://github.com/Softmotions/ejdb.
The query syntax is similar to mongodb.
We use this at work - https://github.com/flapdoodle-oss/embedmongo.flapdoodle.de - to fire up embedded Mongo for integration tests. Has worked really well.
I haven't tried it, but I just found this Ruby implementation of an embedded MongoDB: https://github.com/gdb/embedded-mongo

How to tell DB size with MongoID on Heroku?

We're using the MongoHQ addon on Heroku, with the Mongoid 3.0 adapter. The addon plans come with a size limit, and Mongo will silently fail writing when the DB limit has been reached (unless configured for safe mode--in which case it'll throw exceptions).
I'm trying to query from within the app how close we are and send an alert if we've reached the limit. How can I run something like the db.stats() command but using Mongoid?
I've found out how to do this in Mongoid 3.x which uses Moped as driver, not the Ruby driver from 10gen.
It was the author of Moped himself who answered a github issue raised on the matter.
Mongoid.default_session.command(collstats: 'collection_name')
This will return the same results as db.stats() from the Mongo console. As an additional bonus, if the collection is capped, there'll be a flag in the return values indicating that.
You can call the ".db" method on your object (e.g. a Document), and do .stats on it.
For example:
MyBlog.db.stats
For verisons prior to Mongoid 3.0.0, Mongoid.master.stats should also work.

How to log all Doctrine queries to file?

I'm using Doctrine and want to log all generated SQL queries.
I know that I could use $q->getSqlQuery() but I don't want to do that manually each time.
Is there a way to do it automatically?
If you turn logging on all queries shoudl be logged to your application log in the log directory. To do this set logging_enabled to true in your settings.yml.
Take a look at Doctrine Profiler and the source of ZF_Debug & Doctrine.

Resources