Skip to main content


Showing posts from June, 2016

$sample operator in MongoDB

If we want select document randomly in fixed number of document then we have to use $sample. $sample operator randomly selects specific number of data from input.

{ $sample: { size: <positive integer> } }

Note: If size is greater than or equal to 5% of data (total documents), $sample scan the collection and sort the document.If size is less than 5% of data (total documents) then $sample use the pseudo random cursor on the collection if using WiredTiger Storage Engine.$sample use the _id to select random data if using MMAPv1 Storage Engine.$sample can select same document more than once in its result set.
Example: Suppose we have a collection named Books and wants to select 3 document randomly.

{ "_id" : 1, "Book Title": "book1", "price" : 20, "quantity" : 1, "date" : ISODate("2016-08-05T07:00:00Z") } { "_id" : 2, " Book Title " : " book2", "price" : 10, "…

$out operator in MongoDB

$out is responsible to write a specific collection taking documents returned by aggregation pipeline. We should keep $out at the last stage in the pipeline. $out operator give the facility to return result set of any size.

{ $out: "<output-collection>" }

When you use $out operator it create a new collection in current data base, It just like a view in SQL Server but it create as table. If you want to aggregate some document from collection and want to write in a new collection then you have to use $out operator in mongodb. $out operator create new collection if aggregation succeed if aggregation failed It will not create a collection.
$out operation replace the existing collection if already exists in current database, mean if you are performing aggregation using $out operation and collection already exist in database which is specified by $out, it replaces the existing collection with $out specify collection. If operation filed then no changes make in database. …

Introduction to SQL Server 2016

Chapter 1

SQL Server 2016 is the latest edition of Microsoft SQL Server Database. SQL Server 2016 came with a variety of new features and enhancements that deliver breakthrough performance, advanced security, integrated reporting, and capabilities. Many features have been incorporated in SQL Server 2016 which introduced first in the cloud in Microsoft Azure SQL Database.  SQL Server includes the capability to dynamically migrate historical data to the cloud.
Some Enchantment and features are given below.
Faster Queries:
In SQL Server faster queries were the major problem, a user wants to data access more as you can give him.  SQL Server 2016 gives several options to for enabling faster query. Memory- optimization table now support even faster online transaction processing (OLTP) workloads, with better throughput as a result of new parallelized operations.For analytic workloads, you can take advantage of updateable, clustered columnstore indexes on memory-optimized tables to achieve queries…