컴퓨터언어/Database(38)
-
Expressions with $project
db.movies.aggregate([ { $match: { cast: { $elemMatch: { $exists: true } }, directors: { $elemMatch: { $exists: true } }, writers: { $elemMatch: { $exists: true } } } }, { $project: { _id: 0, cast: 1, directors: 1, writers: { $map: { input: "$writers", as: "writer", in: { $arrayElemAt: [ { $split: ["$$writer", " ("] }, 0 ] } } } } }, { $project: { labor_of_love: { $gt: [ { $size: { $setIntersecti..
2021.02.04 -
Chapter 1: Basic Aggregation - $match and $project
Shaping documents with $project The correct answers are the following: Once we specify a field to retain or perform some computation in a $project stage, we must specify all fields we wish to retain. The only exception to this is the _id field. $project implicitly removes all other fields once we have retained, reshaped, or computed a new field. The exception to this is the _id field, which we m..
2021.02.03 -
max_user_connection 초과라고? 내 코드에 문제가 있는 거 아닐까?
python - flask - mariadb를 사용하던 중 자꾸 max_user_connection을 초과하는 상황이 생겼다. 처음에는 timeout을 짧게 해서 오래된 프로세스를 강제종료 시켜야 하나 싶었다. 하지만 뭔가 찜찜했다. 명색이 많은 사람이 함께 쓰기 위해 존재하는 데이터베이스지 않은가? 아무리 root권한이 없다고 해도 timeout을 만지면서까지 user_connection을 해결하는건 좀 이상하지 않나? 역시 모든 문제는 나로부터 시작된 것. connection을 열기만 하고 닫지를 않아서 프로세스가 증식했던 것이다. 누수가 생기는 것은 아닌지 잘 확인하고 다닐 것! conn.close();
2021.02.01 -
[MongoDB University] 정리
파이프라인 : $match(일치모양골라내기) -> $project(형태변형) -> $group(단일파일로만들어전체에대한비율계산) Stages cannot be configured to produce our desired output. This is definitely not correct. Stages can be configured in almost any way we desire. Pipelines must consist of at least two stages. This is not correct. Pipelines must consist of at least one stage, and can have many stages. Documents flow through the pipeline, pass..
2021.02.01 -
[반정규화] 테이블 분할의 단점 (Feat. 정규화vs반정규화)
👍 테이블 분할이란? 정규화 != 테이블분할(반정규화의 방법 중 하나) 데이터의 무결성을 확보하기 위해서는 정규화를 실시하는 것이 일반적이지만, 오히려 정규화 때문에 쪼개진 테이블이 서로 연산하기 위해 트랜잭션이 증가하여 비용이 높게 청구된다면, 무결성을 포기하는 대신 반정규화를 실시하게 된다. 그런데 여기서 혼동의 우려가 있는데, 정규화도 테이블을 쪼개는 과정이지만, 반정규화에도 "테이블 분할"이라는 방식이 존재한다는 것이다. 그래서 차이점을 정확히 알아야 한다. "정규화"로서의 테이블 쪼개기와 "반정규화의 테이블 분할"로서의 테이블 쪼개기는 각각 유형이 따로 정해져 있다. 정규화로서의 테이블 쪼개기는 테이블이 원자성을 보유하거나, 부분함수종속성/이행함수종속성을 탈피하도록 각각의 단계에 맞추어 테이블을..
2020.08.03 -
[MissingUsernameError, show dbs] - Mongo를 다룰 때 사소한 실수
1. MissingUsernameError?! ctor [MissingUsernameError]: No username was given 유저로부터 HTML 폼 양식을 통해 입력받은 데이터를 MongoDB에 추가하려고 할 때, 위와 같은 오류가 나왔었다. 이럴 때는 form의 input 중 name 속성을 빠뜨린 것이 있는지 다시 한번 확인하자. 2. 왜 내가 만든 db가 목록에 안뜰까? > show dbs show dbs 명령어를 쳤는데도 내가 새로 만든 Database가 나타나지 않는 것은, 내가 아직 어떠한 데이터도 생성하지 않았기 때문이다. 어서 collection을 생성하러 가자. 3. passport로 로그인 시 자꾸만 원하는 페이지로는 안가고 failureRedirect만 해요! 분명 눈을 ..
2020.07.22