I always run the compact command on mongodb and it disturb the performance of the DB , do you know if adding Background : true will work ? I'm asking before testing it .
db.runCommand({compact:'OPC_PLANT_DATA'}, {'background' : true})
Related
If I have records in mongoDb without "_class" property, query by example does not work. My database is populated by third-party non-java microservice, by the way.
Example:
{
"_id":"5ec3f00d98326d4c0ead815f",
"first_name":"firstName",
"last_name":"lastName"
}
Then MongoRepository.findAll(Example<S> example) is not able to find that record. If I add correct "_class" field manually, all works as expected.
Has someone solved this issue?
Spring Data mongo v.3.0.0.RC1
Ok, there is UntypedExampleMatcher that must be used in this case:
ExampleMatcher matcher = UntypedExampleMatcher.matching()
.withIgnoreNullValues()
.withIgnoreCase();
Entity probe = ...
Example<Entity> entityExample = Example.of(probe, matcher);
entityRepo.findAll(entityExample);
But this approach does not work by some reason. It is very long-running, and ends with exception at the end.
UPDATE:
Because of incorrect "probe", my request tried to fetch from DB thousands of records, therefore it ended up with exception. After fixing it, search with QBE approach works as a charm.
I'm trying to populate my graph on IBM Graph service using gremlin queries. I'm using addVertex and I'm doing it in batches. The gremlin I'm using looks like this and it seems slow
{"gremlin":
"def g = graph.traversal();
graph.addVertex(T.label, "foo")";
.
.
.
}
Is there a way to speed this up
The problem with this script is that it will be compiled every time and that takes time. If you have 100's of these then the time to compile each one will definitely add up. A Better way to do is to write the script once and then bind the variables in a bindings object.
{
"gremlin": "def g = graph.traversal();graph.addVertex(T.label, name)",
"bindings": { "name": "foo" }
}
This technique will pretty much work with any database that's built on top of Tinkerpop and uses Gremlin as a DSL
does anybody knows how it's possible to use the "force index" function on a mysql query in cakephp3 ORM?
i found some soloutions for cakephp2, but nothing for cakephp3. I know that's possible to make a raw query, but i prefer a way to use it with the cakephp orm.
thank you for your help. :-)
This isn't supported out of the box. For a clean implementation you'd have to create custom/extened query and query compiler classes to add such functionality, something similar to Query::modifiers().
https://github.com/cakephp/cakephp/blob/3.1.3/src/Database/Query.php#L357
https://github.com/cakephp/cakephp/blob/3.1.3/src/Database/QueryCompiler.php#L140
The only other way I can think of, would be to slip it in via Query::from(), however this feels kinda akward, and more of a workaround.
$query = $Table->find();
$query->from($query->newExpr('table_name TableAlias FORCE INDEX (index_name)'), true);
A little more dynamic:
$table = $Table->table();
$alias = $Table->alias();
$query->from($query->newExpr($table . ' ' . $alias . ' FORCE INDEX (index_name)'), true);
See also
API > \Cake\Database\Query::from()
Cookbook > Database Access & ORM > Query Builder > Raw Expressions
This must be something very simple, I just don't see it (and can not find the answer :(
I am trying to learn DevExpress controls and have read that eXpress Persistent Objects is recommended for O/R mapping.
1) I have an existing SQL Server Compact 4.0 database for which I generated ORM
2) I have a Winform with XtraGrid.GridControl gridControl1
3) In Form_Load event I have this code:
XPCollection cName = new XPCollection(typeof(WindowsFormsApplication1.DUzskv1r6.XPO_TableName));
int c = cName.Count; //didn't help...
cName.DisplayableProperties = "Name;Nr"; //choose columns to display
gridControl1.MainView.PopulateColumns();
gridControl1.DataSource = cName;
I have read that it using "delayed loading" - loading when it is necessary (http://documentation.devexpress.com/#XPO/clsDevExpressXpoXPCollectiontopic), but reading XPcollections record Count didn't do the trick as it was suggested.
As a result I get an empty gridControl1 with columns "Name" and "Nr".
Please help - what am I missing?
I think the issue is somewhere in your datalayer initialization.
You use XPCollection with default session, maybe you forgot to initialize it.
The best way is to specify the session is in the XPCollection contractor.
I want to access two databases in Play Scala with anorm and Magic[T], (one is H2 and another is PostgreSQL). I just don't know how to config it...
I noticed that we can set another database connection in conf/application.conf
db_other.url=jdbc:mysql://localhost/test
db_other.driver=com.mysql.jdbc.Driver
db_other.user=root
db_other.pass=
However, how can I use it with Magic?
(I read the source code of Magic but don't understand it... my am a freshman of Scala)
Anyhow, if multiple database access is impossible with Magic[T] , I wish to do it with anorm, then how can I config it?
var sqlQuery = SQL( //I guess some config params should be set here, but how?
"""
select * from Country
"""
)
In play.api.db.DB it appears you can pass in a string of the name you defined in application.conf.
Then use one of the methods specified here: http://www.playframework.org/documentation/2.0/ScalaDatabase
# play.api.db.DB.class
def withConnection[A](name : scala.Predef.String)(block : scala.Function1[java.sql.Connection, A])(implicit app : play.api.Application) : A = { /* compiled code */ }