Basic database (MongoDB) performance question - ruby-on-rails

I'm building a web app for bookmark storage with a directory system.
I've already got these collections set up:
Path(s)
---> Directories (embedded documents)
---> Links (embedded documents)
User(s)
So performance wise, should I:
- add the user id to the created path
- embed the whole Paths collection into the specific user
I want to pick option 2, but yeah, I dunno...
EDIT:
I was also thinking about making the whole interface ajaxified. So, that means I'll load the directories and links from a specific path (from the logged in user) through ajax. That way, it's faster and I don't have to touch the user collection. Maybe that changes things?
Like I've said in the comments, 1 huge collection in the whole database seems kinda strange. Right?

Well the main purpose of the mongoDB is to support redundant data.I will recommend second option is better because In your scenario what I feel that if you embed path collection into the specific user then by using only single query you can get all data about user as well as related to path collection as well.
And if you follow first option then you have to fire two separates queries to get all data which will increase your work somewhat.
As mongodb brings data into the RAM so after getting data from one collection you can store it into cursor and from that cursor data you can fetch data from another collection. So if we see performance wise I dont think it will affect a lot.

RE: the edit. If you are going to store everything in a single doc and use embedded docs, then when you make your queries make sure you just select the data you need, otherwise you will load the whole doc including the embedded docs.

Related

How to save a query in Dremio?

Dremio provides a really nice GUI to download and save data generated after your query run.
However, I want to save my query (instead of query result) in dremio so that I can anytime (in future) refer the query that I wrote. Is there a way to achieve this?
Really appreciate the help!
Although this is an old post, I thought it might be helpful to provide a solution. What you are describing can be solved with a key functionality of Dremio. Instead of going through the difficulty of searching for your old query; I would have suggested creating a VDS (Virtual Data Set) by way of the UI. After a successful run of your query you can save it
Dremio Save Dataset Button as a VDS.
After selecting the save button you will be asked where you wish to save it; you can either save it to your default directory or a named Space you have created previously Dremio VDS Save Dialog.
You can query against this new VDS as though it was an actual table. Any changes made to the VDS will be saved in a history - utilizing the breadcrumb trail on the right side of the UI one can navigate to prior versions.
You can now further accelerate this query through creation of a Dremio Reflection...but that goes beyond the scope of your question ;)
In the left upper corner, you should look for Jobs menu:

Best design pattern to handle iOS Application State/Data

I am starting a new project (learning purposes) and I am trying to figure out what is the best software design pattern to use in the following scenario.
I have several data that need to be downloaded from multiple webservices and store somewhere in my app, to display it later. However each piece of data (e.g. list of teachers, students) will only be used in one or more specific view controllers (e.g. teachersViewController and studentsViewController).
I read that the Singleton pattern or use the AppDelegate to store a variable (an object like ApplicationData) is a bad practise, even more in this example which I want to restrict the data access.
So, which design pattern should I choose? I have read something about dependency injection, but I don't have any clue about it or if it even helps me in this question. If it helps, some examples with explanation would be nice.
You need some sort of database to store downloaded data. Good choices are Realm and Core Data. The right way to process data is:
Check if data is already in DB and show it if available.
Download or update data from server and parse it to objects.
Save objects to DB.
Show data taken from DB to user.
Download data as needed. When you open VC with students then download only students data and so on.
EDITED: If you need all the data on app open then load it and put in a DB before first screen opens. Then just use DB to show data to user.

Any Special Considerations when using multiple UIManagedDocuments in iOS

I've been using a UIManagedDocument inside of a Singleton class. I create, open and perform with etc and everything was going fine until I needed to have two separate Data stores with an identical Schema. I've made sure everything was done in the same way through the same class (simply storing the second Database in a second static variable and using a BOOL to ensure the correct document gets used.
The problem is that while my original document works fine and the second document gets created fine, I can never seem to get the second document to open when I call 'openWithCompletionHandler' and pass in the block I need it to perform.
So my question is: Are there any special considerations I need to take into account when using multiple UIManagedDocuments in the one project?
Thanks in advance.
Yes there are. The big one is to make sure they both have unique NSPersistentStoreUbiquitousContentNameKey values set in the document's persistentStoreOptions.
See Rich Warren's well documented example:
Syncing Multiple Core Data Documents Using iCloud
And also my GitHub repo that makes multiple documents easier to set up and maintain in some cases:
APManagedDocument

Rails - Store unique data for each open tab/window

I have an application that has different data sets depending on which company the user has currently selected (dropdown box on sidebar currently used to set a session variable).
My client has expressed a desire to have the ability to work on multiple different data sets from a single browser simultaneously. Hence, sessions no longer cut it.
Googling seems to imply get or post data along with every request is the way, which was my first guess. Is there a better/easier/rails way to achieve this?
You have a few options here, but as you point out, the session system won't work for you since it is global across all instances of the same browser.
The standard approach is to add something to the URL that identifies the context in which to execute. This could be as simple as a prefix like /companyx/users instead of /users where you're fetching the company slug and using that as a scope. Generally you do this by having a controller base class that does this work for you, then inherit from that for all other controllers that will be affected the same way.
Another approach is to move the company identifying component from the URL to the host name. This is common amongst software-as-a-service providers because it makes sharding your application much easier. Instead of myapp.com/companyx/users you'd have companyx.myapp.com/users. This has the advantage of preserving the existing URL structure, and when you have large amounts of data, you can partition your app by customer into different databases without a lot of headache.
The answer you found with tagging all the URLs using a GET token or a POST field is not going to work very well. For one, it's messy, and secondly, a site with every link being a POST is very annoying to work with as it makes navigating with the back-button or forcing a reload troublesome. The reason it has seen use is because out of the box PHP and ASP do not have support routes, so people have had to make do.
You can create a temporary database table, or use a key-value database and store all data you need in it. The uniq key can be used as a window id. Furthermore, you have to add this window id to each link. So you can receive the corresponding data for each browser tab out of the database and store it in the session, object,...
If you have an object, lets say #data, you can store it in the database using Marshal.dump and get it back with Marshal.load.

Dynamic DB links in Oracle

Is it possible to have dynamic database links in Oracle? I am using Oracle9i database.
Let me illustrate by what I require.
I have several views that are formed using dblinks.
For example:
CREATE VIEW MYVIEW AS SELECT * FROM TABLE#MYDBLINK.WORLD
mydbLINK.WORLD NEEDS TO POINT TO DIFFERENT INSTANCES OF THE DATABASE. SO AT ONE POINT IT MUST POINT TO THE DATABASESERVER1 AND THEN IT MUST SWITCH TO DATABASESERVER2.
Currently we are doing this by dropping the link and recreating it. When we do this, we have to recompile all the objects, refresh all the snapshots. Is it possible to avoid the dropping and recreating? I understand as soon as teh view changes, I will have to recompile the objects and refresh the snapshots regardless.
Has anyone implemented this feature?
Try using SYNONYMS as suggested by "Justin Cave" in this post.

Resources