nosql

NoSQL那些事--Redis

为君一笑 提交于 2019-12-30 01:22:50
Redis是个流行的内存数据库(in-momery)。接口好用,性能也很强,还支持多种数据结构,加上各种高可用性集群方案,实在是太太太好用了。 但是就是因为太好用了,好用到让很多人都晕了脑子: 用Redis性能就大大提高了 用Redis可以保证原子性 用Redis可以实现事务 用Redis可以当队列 …… 这就好像一个股民,在手机上操作买卖几笔股票,赚了一些,然后感叹道"股市就是为我发财而存在的啊"!!他的下场可想而知。 Redis的种种优势源自于他的设计——简单直接的单线程内存操作。但这些优势是有前提的。 Redis的性能高,吗? Redis的性能非常高。有些评测说用Redis可以达到几十万QPS(比如这里 http://skipperkongen.dk/2013/08/27/how-many-requests-per-second-can-i-get-out-of-redis/ )。大家可能在网文上记住了这个NB的数字,却很少关心这个数值怎么来的。这就像是你买手机评测光看跑分一样不靠谱。 Redis要达到高性能需要做到: Value尽可能的小。一般的测评都会用比较小的value,比如一个整数或者不长的字符串。但是如果用Redis做缓存,那么缓存的大小的可能偏离这个数字。比如一个页面几十KB;再比如,一个5年的市场价格序列数据可能高达几MB

Join operation with NOSQL

梦想的初衷 提交于 2019-12-29 10:28:13
问题 I have gone through some articles regarding Bigtable and NOSQL. It is very interesting that they avoid JOIN operations. As a basic example, let's take Employee and Department table and assume the data is spread across multiple tables / servers. Just want to know, if data is spread across multiple servers, how do we do JOIN or UNION operations? 回答1: When you have extremely large data, you probably want to avoid joins. This is because the overhead of an individual key lookup is relatively large

NoSql Crash Course/Tutorial [closed]

我只是一个虾纸丫 提交于 2019-12-29 10:03:09
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I've seen NoSQL pop up quite a bit on SO and I have a solid understanding of why you would use it (from here, Wikipedia, etc). This could be due to the lack of concrete and uniform definition of what it is (more of a paradigm than concrete implementation), but I'm struggling to wrap my head around how I would go

Reasonable Export of Relational to Non-Relational Data

Deadly 提交于 2019-12-29 08:25:08
问题 We have different products that rely on relational databases for various reasons, basically the transactional nature of the operations (atomicity, consistency, etc.). This is not going to change any time soon. Given this scenario, are there any possible justifications to export the data to a NoSQL solution? Maybe Datawarehousing, Analytics, etc. Any comments are welcome. 回答1: "Data" is just a vague generality without a data structure. "Relational" means the data structure is relations/tables

MongodDB $pull only one element from array [duplicate]

醉酒当歌 提交于 2019-12-29 06:56:32
问题 This question already has answers here : How to pull one instance of an item in an array in MongoDB? (2 answers) Closed 2 years ago . I have a document with an array inside, like this: "userTags" : [ "foo", "foo", "foo", "foo", "moo", "bar" ] If I perform db.products.update({criteriaToGetDocument}, {$push: {userTags: "foo"}}} I can correctly insert another instance of foo into the array. However, if I do db.products.update({criteriaToGetDocument}, {$pull: {userTags: "foo"}}} then it removes

MongodDB $pull only one element from array [duplicate]

半世苍凉 提交于 2019-12-29 06:55:07
问题 This question already has answers here : How to pull one instance of an item in an array in MongoDB? (2 answers) Closed 2 years ago . I have a document with an array inside, like this: "userTags" : [ "foo", "foo", "foo", "foo", "moo", "bar" ] If I perform db.products.update({criteriaToGetDocument}, {$push: {userTags: "foo"}}} I can correctly insert another instance of foo into the array. However, if I do db.products.update({criteriaToGetDocument}, {$pull: {userTags: "foo"}}} then it removes

Cassandra column key auto increment

点点圈 提交于 2019-12-29 05:09:25
问题 I am trying to understand Cassandra and how to structure my column families (CF) but it's quite hard since I am used to relational databases. For example if I create simple users CF and I try to insert new row, how can I make an incremental key like in MySQL? I saw a lot of examples where you would just put the username instead of unique ID and that would make a little sense, but what if I want users to have duplicated usernames? Also how can I make searches when from what I understand

redis配置、安装、集群

大兔子大兔子 提交于 2019-12-28 14:26:27
redis配置、安装、集群 前言 Redis 是我们目前大规模使用的缓存中间件,由于它强大高效而又便捷的功能,得到了广泛的使用。单节点的Redis已经就达到了很高的性能,为了提高可用性我们可以使用Redis集群。 当然了,现在集群的方式有很多,隧道模式(还有更高级的虚拟隧道模式)、行星模型、智能路由、P2P模式,各种各样的,算是各有各的好处吧,也有官方给了一种cluster工具,不过本文不用官方的,因为他的官方的这个是在一个服务器上折腾。。。一台机器死了,直接全崩,有点没必要,本文主要讲 主从模式的redis. redis简介 分布式 - 所谓的分布式就是不是单独跑在一台服务器上的,不管公司花多少钱一台服务器多牛,它也是有极限的,1000t内存也是极限,所以单台服务器风险还是比较大的,万一它死了,整个公司完全瘫了也不合适。 所以分布式就是说让我这一个服务是部署在一个一个的服务器上,这样的话就算是有一个服务器因为各种各样的原因瘫了,没关系,继续跑,只不过整个系统性能会有所下降,然后过一段时间等这些节点重新恢复了它又可以接入分布式的系统当中。 内存数据存储 - noSQL 咱们知道跟数据库所有的打交道都需要用SQL语言来完成,结构化查询语言。 它有的时候也叫noSQL,因为咱们那个数据库,说实话它很强,各种关系,各种乱七八糟的东西,但是数据库,它更适合复杂的查询,对于简单的查询

MongoDB: Terrible MapReduce Performance

那年仲夏 提交于 2019-12-28 07:39:07
问题 I have a long history with relational databases, but I'm new to MongoDB and MapReduce, so I'm almost positive I must be doing something wrong. I'll jump right into the question. Sorry if it's long. I have a database table in MySQL that tracks the number of member profile views for each day. For testing it has 10,000,000 rows. CREATE TABLE `profile_views` ( `id` int(10) unsigned NOT NULL auto_increment, `username` varchar(20) NOT NULL, `day` date NOT NULL, `views` int(10) unsigned default '0',

Use more than one schema per collection on mongodb

﹥>﹥吖頭↗ 提交于 2019-12-28 05:17:09
问题 I wanted to use more than one schema per collection in mongodb , how to use it....? It gives me this error when I try to run it: Error: OverwriteModelError: Cannot overwrite allUsers model once compiled. OverwriteModelError: Cannot overwrite checkInOut model once compiled. Heres my schema.js var mongoose = require('mongoose'); var Schema = mongoose.Schema , ObjectId = Schema.ObjectId; var checkInInfoSchema= new Schema({ name:String, loginSerialId:Number }); var loginUserSchema = new Schema({