search
HomeDatabaseRedisThe difference between es and 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
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
Redis: Database or Server? Demystifying the RoleRedis: Database or Server? Demystifying the RoleApr 28, 2025 am 12:06 AM

Redisisbothadatabaseandaserver.1)Asadatabase,itusesin-memorystorageforfastaccess,idealforreal-timeapplicationsandcaching.2)Asaserver,itsupportspub/submessagingandLuascriptingforreal-timecommunicationandserver-sideoperations.

Redis: The Advantages of a NoSQL ApproachRedis: The Advantages of a NoSQL ApproachApr 27, 2025 am 12:09 AM

Redis is a NoSQL database that provides high performance and flexibility. 1) Store data through key-value pairs, suitable for processing large-scale data and high concurrency. 2) Memory storage and single-threaded models ensure fast read and write and atomicity. 3) Use RDB and AOF mechanisms to persist data, supporting high availability and scale-out.

Redis: Understanding Its Architecture and PurposeRedis: Understanding Its Architecture and PurposeApr 26, 2025 am 12:11 AM

Redis is a memory data structure storage system, mainly used as a database, cache and message broker. Its core features include single-threaded model, I/O multiplexing, persistence mechanism, replication and clustering functions. Redis is commonly used in practical applications for caching, session storage, and message queues. It can significantly improve its performance by selecting the right data structure, using pipelines and transactions, and monitoring and tuning.

Redis vs. SQL Databases: Key DifferencesRedis vs. SQL Databases: Key DifferencesApr 25, 2025 am 12:02 AM

The main difference between Redis and SQL databases is that Redis is an in-memory database, suitable for high performance and flexibility requirements; SQL database is a relational database, suitable for complex queries and data consistency requirements. Specifically, 1) Redis provides high-speed data access and caching services, supports multiple data types, suitable for caching and real-time data processing; 2) SQL database manages data through a table structure, supports complex queries and transaction processing, and is suitable for scenarios such as e-commerce and financial systems that require data consistency.

Redis: How It Acts as a Data Store and ServiceRedis: How It Acts as a Data Store and ServiceApr 24, 2025 am 12:08 AM

Redisactsasbothadatastoreandaservice.1)Asadatastore,itusesin-memorystorageforfastoperations,supportingvariousdatastructureslikekey-valuepairsandsortedsets.2)Asaservice,itprovidesfunctionalitieslikepub/submessagingandLuascriptingforcomplexoperationsan

Redis vs. Other Databases: A Comparative AnalysisRedis vs. Other Databases: A Comparative AnalysisApr 23, 2025 am 12:16 AM

Compared with other databases, Redis has the following unique advantages: 1) extremely fast speed, and read and write operations are usually at the microsecond level; 2) supports rich data structures and operations; 3) flexible usage scenarios such as caches, counters and publish subscriptions. When choosing Redis or other databases, it depends on the specific needs and scenarios. Redis performs well in high-performance and low-latency applications.

Redis's Role: Exploring the Data Storage and Management CapabilitiesRedis's Role: Exploring the Data Storage and Management CapabilitiesApr 22, 2025 am 12:10 AM

Redis plays a key role in data storage and management, and has become the core of modern applications through its multiple data structures and persistence mechanisms. 1) Redis supports data structures such as strings, lists, collections, ordered collections and hash tables, and is suitable for cache and complex business logic. 2) Through two persistence methods, RDB and AOF, Redis ensures reliable storage and rapid recovery of data.

Redis: Understanding NoSQL ConceptsRedis: Understanding NoSQL ConceptsApr 21, 2025 am 12:04 AM

Redis is a NoSQL database suitable for efficient storage and access of large-scale data. 1.Redis is an open source memory data structure storage system that supports multiple data structures. 2. It provides extremely fast read and write speeds, suitable for caching, session management, etc. 3.Redis supports persistence and ensures data security through RDB and AOF. 4. Usage examples include basic key-value pair operations and advanced collection deduplication functions. 5. Common errors include connection problems, data type mismatch and memory overflow, so you need to pay attention to debugging. 6. Performance optimization suggestions include selecting the appropriate data structure and setting up memory elimination strategies.

See all articles

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.