smali

пятница, 21 сентября 2018 г.

MongoDB: Index Usage and MongoDB explain() (Part 1)

https://dzone.com/articles/mongodb-index-usage-and-mongodb-explain-part-1

In this two-part series, I'm going to explain explain. No, the repetition is not a pun or a typo. I'm talking about explain(), the most useful MongoDB feature to investigate a query. Here, I'll introduce the index types available in MongoDB, their properties, and how to create and use them. In the next article, we'll see explain() in action on some real examples.
Using explain(), questions like these will find a proper answer:
  • Is the query using an index?
  • How is it using the index?
  • How many documents are scanned?
  • How many documents are returned?
  • For how many milliseconds does the query run?
And many others. The explain() command provides a lot of information.
If you are familiar with MySQL, then you probably know about the command EXPLAIN. In MongoDB, we have a similar feature, and the goal of using it is exactly the same: find out how we can improve a query in order to reduce the execution time as far as possible. Based on the information provided, we can decide to create a new index or to rewrite the query to take advantage of indexes that already exist. The same as you do when using MySQL.

MongoDB: Investigate Queries With explain() and Index Usage (Part 2)

https://dzone.com/articles/mongodb-investigate-queries-with-explain-and-index?edition=399207&utm_source=Zone%20Newsletter&utm_medium=email&utm_campaign=database%202018-09-21

This is the second part of a two-part series. In MongoDB: Index Usage and MongoDB explain(), we introduced the main index types supported by MongoDB and how to create and use them. In this second article, we are going to see some examples of how to use the explain() method to investigate queries. Do you need to optimize MongoDB queries? You'll see how to use explain() to find out how your query uses indexes. Or, perhaps, that it doesn't use indexes!

What Is explain()?

explain() is a method that you can apply to simple queries or to cursors to investigate the query execution plan. The execution plan is how MongoDB resolves a query. Looking at all the information returned by explain(), we can see find out stuff like:
  • how many documents were scanned
  • how many documents were returned
  • which index was used
  • how long the query took to be executed
  • which alternative execution plans were evaluated
...and other useful information.
The aim of using explain() is to find out how to improve the query, for example, by creating missing indexes or by rewriting it in order to use existing indexes more correctly. If you are familiar with the EXPLAIN command in MySQL, the goals of MongoDB's explain() method are exactly the same.

Query Databases Using Java Streams

https://dzone.com/articles/query-databases-using-java-streams?edition=399207&utm_source=Zone%20Newsletter&utm_medium=email&utm_campaign=database%202018-09-21

Query Databases Using Java Streams

In this article, you will learn how you can write pure Java applications that are able to work with data from an existing database without writing a single line of SQL (or similar languages like HQL) and without spending hours putting everything together. After your application is ready, you will learn how to accelerate latency performance with a factor of more than 1,000 using in-JVM-acceleration by adding just two lines of code.
Throughout this article, we will use Speedment, which is a Java stream ORM that can generate code directly from a database schema and that can automatically render Java Streams directly to SQL, allowing you to write code in pure Java.
You will also discover that data access performance can increase significantly by means of an in-JVM-memory technology where Streams are run directly from RAM.