Tag Info

New answers tagged

0

You can not get all the types from a csv or json file. Lets check the following example: asd;3534;0674;slfo What are the types? The third column with the value 0674 contains a string or an integer, decimal, float or what? Has that leading 0 any meaning? If so, it should be a string/character data. The case is similar with the JSON files: Dates are ...


0

You want to use bulk write operations instead of individual updates and inserts. // BEFORE your iteration loop var bulk = db.another_collection.initializeUnorderedBulkOp(); // INSIDE your iteration loop // instead of db.another_collection.update(…) bulk.find(query).update(yourUpdateDocumentHere); // instead of db.another_collection.insert(…) ...


1

Once you have a cursor, you'll want to call readPref('secondary') on it. http://docs.mongodb.org/manual/reference/method/cursor.readPref/#cursor.readPref And I think you mean replica instead of shard.


1

You have two options: 1) The safest is to use on your driver the "secondary" option as described on the below article: http://docs.mongodb.org/manual/reference/read-preference/ 2) Another option is to tag your secondaries as described below and target your queries against the tag, most drivers offer that option. Disadvantage is that you have to ensure ...


0

It depends from the distribution of your inserts if moves going to occur and how many. 1) you start with one chunk {minkey,maxkey} which lives on primary (lets say shard000) 2) as you insert data a split will occur. Might be 2.1) {minkey, US} {US,maxkey} -> moves the second chunk to shar001 2.2) {minkey, TR} {TR,maxkey} -> moves first chunk to shard001 ...


0

The problem (from what I can see) From what I can see from your output, you have a monotonically increasing shard key like ÒbjectIdor aDate` or something similar. MongoDB sharding is done with key ranges over the selected shard key. Put simply, it works like "shard0000 is supposed to hold the rang from -infinity to $i, shard0001 the keys from $h to $p and ...


1

In my opinion if your fragmentation is not over 15-20% its not worth doing that (except if you are running out of disk space). What i would do is: 1) Add an arbiter to each replica set (optional) 2) Shutdown one of the secondaries and delete the data directory 3) Start the secondary and let it do the initial sync which removes fragmentation (at this ...


2

Yes you can with a single command: db.getSiblingDB('admin').runcommand({ movePrimary : "YourDBName", to : "shard001" }) then is important to flush configuration on all mongos (suppose all than the one that did the move, but better be safe): db.adminCommand({flushRouterConfig: 1}) If your databases are small you can do it on-the-fly, else you better plan ...


0

All targeted updates (multi: false so targeting a single document) must contain enough information to target a single document in order to be routed correctly (i.e. the shard key, or the _id of the document being targeted). To understand why, consider what would happen with your attempted update. You have said (by stating multi: false that you only want one ...


0

First off, to correct the comment: the profiler does not write to the local database, it writes to whatever database you are profiling in the system.profile collection. So if you were reading from database foo and had profiling turned on, the collection would be foo.system.profile. You could turn on profiling for the local database, and hence have the ...


1

This is a common misconception, i.e. that yields are somehow causing the slowness. In fact they are a symptom, not a cause. Even if there is no lock contention that requires a yield (writes basically), the queries still yield when they have to page from disk. They then re-acquire the lock when a certain amount of paging is done and look to yield again if ...


2

Short version: use a manual reference, not a DBRef. Explanation: There is no particular benefit to the use of a DBRef beyond giving you the collection and database that the referenced document resides in. If you know the reference is only between categories and products, then that is not particularly useful. A DBRef simply contains the _id of the ...


0

Delete just put a flag on the document that is deleted. I am not sure but i think it doesn't reorganize the indexes at the same time, if that is your question, because reorganize the b-tree is an expensive operation.


0

The query db.cars.find( { "car_type" : 507c35dd8fada716c89d0013 } ); actually would be used and imho is the best solution in this case. In order to make this query efficient, however, you would create an index db.cars.ensureIndex({"car_type":1}) In this case, linking two documents makes sense. There are other relations in which embedding documents ...


0

In MySQL, or almost any other RDBMS, it is common to have an ID for the row (object), so you use it in other tables to make a link between the tables (Relations, or PK and FK if you prefer). This is part of the normalization process that is recommended for most types of DB design [there are exceptions though]. In MongoDB however, the general way or design ...


0

The reason of the problem was wrong index selection. Somehow Mongo was selecting wrong index and was using it for 20–40 seconds. Not sure, if it was caused by memory flushing or not. There were rare records with large nscanned in slow logs. We hot-fixed it with planCacheSetFilter.


2

The write is done in-memory first and flushed to disk (asynchronously) later. Any readers accessing a document will get the in-memory copy straight away, not waiting for the flush to disk to happen (otherwise the database would be disk bound in terms of performance). The reference about locks applies to the in-memory portion, and guarantees the atomicity ...


0

It turns out that the host wasn't properly added to /etc/hosts. Adding it seemed to solve the problem.


1

Here are several examples of YAML configs for Linux (Windows paths and options are a little different), essentially explicitly setting some defaults and commonly used settings. First, a standalone mongod with the default port, path, journal settings - this would be the type of configuration used for local testing, with a few extras so show the general ...


2

So let's look at the "roles" here represented in the referenced architecture. Keep in mind, this is the "2 cent tour" of what the architecture is all about. Mongos This process is the "router" in that it acts as the interface for a "client" to connect to a sharded cluster. You can have many mongos instances, so you are not limited to "one" only. As ...


0

How it is done Basically, it is easy: Set up three(!) config servers Start a mongos query router and have the --configdb option string point to the three config servers. Note: the string has to be identical on all mongos Restart your going to be shard with the shardsvr option set. This step isn't strictly necessary, but best practise. What this basically ...


0

The data is not being lost - that message means that when the migration was attempted from the source shard to the target, there was already data present that matched the chunk range, which was then deleted (this is what is supposed to happen, which is why that is not an error, but a warning). Since you are starting from scratch, it implies that you have ...


0

You can copy an entire database across in this manner, by copying the files to a new instance, but not collections. You also cannot simply copy the database files from database foo and alter the filenames at the filesystem level (to bar.0, bar.1 etc.) to avoid namespace collisions, the name must remain the same. If you wish to move a single collection (or ...


0

For anyone who's curious, I ended up doing it the first way: Insert a re-post doc in posts docs collection. The doc inserted doesn't contain any of the re-posted doc's info, just a reference to its ID under a "reposted_id" field. It also includes info about the reposter. The query for the feed will match either the author ID or the reposter ID. From the ...


0

In the dump you have above, I see this error SocketException: remote: xx.xx.xx.xx:27017 error: 9001 socket exception [RECV_ERROR] server [168.63.252.61:27017] 2014-11-02T22:53:29.099+0000 [rsSync] DBClientCursor::init call() failed 2014-11-02T22:53:29.307+0000 [rsSync] replSet initial sync exception: 13386 socket error for mapping query 0 ...


0

You could configure sharding because 2Gb limit only applies to individual mongodb processes. Pls refer the documentation sharded-clusters


0

Your tittle and the body doesn't fit. You may need to increase to TcpNumConnections and MaxUserPort but without providing server CPU, RAM , IO its hard to tell if your server can handle multiple connections. To boost the speed of read use sharding and improve your queries.


3

I give a full explanation of what happens with a chunk migration in the M202 Advanced course if you are interested. In general terms, let's just say that migrations are not very fast, even for empty chunks, because of the housekeeping being performed to make sure migrations work in an active system (these still happen even if nothing but balancing is ...


2

i have used PostGIS for over a decade now and I can tell you for sure that there is no match for it in the NoSQL world. how many rows do you have? how large is the thing? Mongo is definitely not going to make you happy. I am pretty sure you did something fishy on the PostgreSQL side to even consider using Mongo. Let us fix it ...


-1

there is absolutely nothing special about it. absolutely zero; nothing. if you want REALLY advanced indexing -> use PostgreSQL.


1

PostgreSQL is perfectly fine for this. You got a couple of options to make this work. First of all: PostgreSQL has a special index type for that called GIN (http://www.cybertec.at/gin-just-an-index-type/). It is perfect for full-text-search in general. The cool thing is: In the latest version of PostgreSQL there is support for a thing called jsonb. You ...



Top 50 recent answers are included