Table of Contents
The difference between es and redis
Home Database Redis The difference between es and redis

The difference between es and redis

Jul 06, 2019 pm 01:45 PM
redis

The difference between es and redis

The difference between es and redis

ElasticSearch

Course Recommendation →: "Elasticsearch Full Text Search Practical Combat" (Practical Video)

From the Course "Ten Million Level Data Concurrency Solution (Theoretical Practical Combat)"

Compared with MongoDB and Redis, ES, which was released a year later, may be less well-known, but ES's reputation in the search engine field is definitely resounding. Compared with other high-end database products, ES has a much more humble background.

The founder of ES, Shay Banon, was once an unemployed programmer. He created ES to facilitate his wife’s search for recipes when he had nothing to do (of course, it was not called ES at the time). Unexpectedly, through unintentional intervention, the most popular search engine database was created today. Sure enough, girls are the biggest motivation for programmers to work!

ES has also established its own Elastic company and has received hundreds of millions of dollars in financing. Shay Banon, the loser programmer at that time, has already counterattacked to become CEO and reached the pinnacle of his life. Programmers, after reading this story, have you already begun to imagine the day when you become CEO and marry Bai Fumei?

The characteristic of ES, as its name suggests, is search. Strictly speaking, ES is not a database, but a search engine, and all aspects of ES are designed around search. ES supports full-text search. Here is a brief explanation of what full-text search is: For data such as "I work in an Internet company in Beijing", if you search for keywords such as "Beijing", "Internet" and "work", you can hit this If there is a piece of data, this is full-text search. Baidu and Google that you use every day are full-text searches.

It is worth mentioning that ES’s full-text search also has good support for Chinese (there are many Chinese word segmenters alone), which can definitely meet the full-text search needs of most people in China. In addition to searching, ES will automatically index all fields for you to achieve high-performance complex aggregation queries. Therefore, as long as the data is stored in ES, no matter how complex the aggregation query is, you can get good performance, and You no longer have to worry about how to create various complex indexes.

Having said so many advantages of ES, do you think ES is almost omnipotent?

Unfortunately not, ES also has many shortcomings. The most obvious ones are that field types cannot be modified, low writing performance and high hardware resource consumption. As mentioned earlier, ES will automatically create indexes for you. Although this can bring many benefits to full-text search and aggregate queries and save you the trouble of building indexes, this feature will also bring a lot of problems.

ES needs to establish Mapping in advance before creating fields. Mapping contains type information of each field. ES needs to establish appropriate indexes for fields based on Mapping. Due to the existence of this Mapping, the type of a field in ES cannot be modified once it is created.

(For example, you forgot to add full-text search to a field in the data table you built. You want to add it temporarily, but the table has already been built and has a lot of data. What should you do at this time? No Sorry, you can only delete the entire data table and rebuild it again!)

Therefore, ES is higher than MySQL in data structure flexibility but far inferior to MongoDB. The shortcomings of ES are not limited to these. Automatic index creation also affects the writing performance of ES, which is significantly lower than MongoDB.

For the same data, the storage space occupied by ES is significantly larger than that of MongoDB (can you build so many indexes without taking up space?), and the consumption of hardware resources is also very powerful. A 64G memory SSD is basically used for large amounts of data. It is standard and can be regarded as an aristocratic service in the database. Therefore, if your boss is very stingy, you should be careful when choosing ES!

The full-text search feature of ES makes it a powerful tool for building search engines. In addition, ES supports complex aggregation queries very well. This feature also makes ES very suitable for data analysis.

In fact, ES has also specially made its own ELK suite to provide you with a one-stop service from log collection to data visualization analysis. It is definitely a powerful tool for building a high-end data analysis platform.

However, the shortcomings of ES's high cost and low writing performance also make it unsuitable for use in scenarios where the data value is not high, writing performance is required, the data volume is large, and the cost is limited. .

Redis

Redis is the most popular key-value database now. It was released in 2009 together with MongoDB and is also a masterpiece of databases in the early big data era.

The biggest feature of Redis is of course the simplicity and high performance brought by key-value storage. The so-called key-value storage means that each record only contains a Key for querying data, and the corresponding value for storing data, just like house numbers and residents in real life, without conventional databases such as tables and fields. Complex concepts that are necessary in , all queries rely only on key values.

Therefore, the key-value database can be said to be the simplest data structure in the database. Thanks to this simple structure, and the fact that Redis will load all data into memory, Redis can achieve much higher results. The read and write performance of conventional databases such as MongoDB. Of course, the function of Redis is not just as simple as key-value storage. Compared with its key-value predecessor Memcached, Redis also supports data persistence, various data structures such as list and set, and a series of functions such as master-slave replication and backup. Therefore, Redis is definitely the most comprehensive and easiest-to-use key-value database.

Redis’ key-value storage brings performance advantages, but it also brings many limitations to complex queries. Since important features such as data tables and fields are eliminated, and all queries rely on keys, Redis cannot provide complex query functions such as multi-column queries and section queries that conventional databases have.

At the same time, because Redis needs to store data in memory, this also greatly limits the amount of data that Redis can store, which also determines that Redis is difficult to use in application scenarios with large data scales.

Redis sacrifices functions such as data tables and complex queries in conventional databases in exchange for great performance improvements. It is especially suitable for those who have extremely high requirements for read and write performance and have simple data table structures (key-value , list, set, etc.), the query conditions are also simple application scenarios.

If your data table structure is quite complex and you often need to do some complex query operations, then you'd better stick to MongoDB or SQL.

For more Redis related knowledge, please visit the Redis usage tutorial column!

The above is the detailed content of The difference between es and redis. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to build the redis cluster mode How to build the redis cluster mode Apr 10, 2025 pm 10:15 PM

Redis cluster mode deploys Redis instances to multiple servers through sharding, improving scalability and availability. The construction steps are as follows: Create odd Redis instances with different ports; Create 3 sentinel instances, monitor Redis instances and failover; configure sentinel configuration files, add monitoring Redis instance information and failover settings; configure Redis instance configuration files, enable cluster mode and specify the cluster information file path; create nodes.conf file, containing information of each Redis instance; start the cluster, execute the create command to create a cluster and specify the number of replicas; log in to the cluster to execute the CLUSTER INFO command to verify the cluster status; make

How to implement the underlying redis How to implement the underlying redis Apr 10, 2025 pm 07:21 PM

Redis uses hash tables to store data and supports data structures such as strings, lists, hash tables, collections and ordered collections. Redis persists data through snapshots (RDB) and append write-only (AOF) mechanisms. Redis uses master-slave replication to improve data availability. Redis uses a single-threaded event loop to handle connections and commands to ensure data atomicity and consistency. Redis sets the expiration time for the key and uses the lazy delete mechanism to delete the expiration key.

How to view all keys in redis How to view all keys in redis Apr 10, 2025 pm 07:15 PM

To view all keys in Redis, there are three ways: use the KEYS command to return all keys that match the specified pattern; use the SCAN command to iterate over the keys and return a set of keys; use the INFO command to get the total number of keys.

How to view the version number of redis How to view the version number of redis Apr 10, 2025 pm 05:57 PM

To view the Redis version number, you can use the following three methods: (1) enter the INFO command, (2) start the server with the --version option, and (3) view the configuration file.

What to do if redis-server can't be found What to do if redis-server can't be found Apr 10, 2025 pm 06:54 PM

Steps to solve the problem that redis-server cannot find: Check the installation to make sure Redis is installed correctly; set the environment variables REDIS_HOST and REDIS_PORT; start the Redis server redis-server; check whether the server is running redis-cli ping.

How to use redis zset How to use redis zset Apr 10, 2025 pm 07:27 PM

Redis Ordered Sets (ZSets) are used to store ordered elements and sort by associated scores. The steps to use ZSet include: 1. Create a ZSet; 2. Add a member; 3. Get a member score; 4. Get a ranking; 5. Get a member in the ranking range; 6. Delete a member; 7. Get the number of elements; 8. Get the number of members in the score range.

How to read the source code of redis How to read the source code of redis Apr 10, 2025 pm 08:27 PM

The best way to understand Redis source code is to go step by step: get familiar with the basics of Redis. Select a specific module or function as the starting point. Start with the entry point of the module or function and view the code line by line. View the code through the function call chain. Be familiar with the underlying data structures used by Redis. Identify the algorithm used by Redis.

How to use the redis command How to use the redis command Apr 10, 2025 pm 08:45 PM

Using the Redis directive requires the following steps: Open the Redis client. Enter the command (verb key value). Provides the required parameters (varies from instruction to instruction). Press Enter to execute the command. Redis returns a response indicating the result of the operation (usually OK or -ERR).

See all articles