[MySQL] 효과적인 대용량 데이터 처리 방법
·
Development/MySql
#20221220 DB 대용량 데이터를 어떻게 처리할지에 대해 고민이다. 일자별로 데이터가 누적되고, 조회도 매일 이루어진다. 조회 조건도 입력에 따라 수시로 변한다. range partition을 사용해볼까 고민 중 이다. MySQL RANGE Partitioning https://dev.mysql.com/doc/refman/8.0/en/partitioning-range.html MySQL :: MySQL 8.0 Reference Manual :: 24.2.1 RANGE Partitioning 24.2.1 RANGE Partitioning A table that is partitioned by range is partitioned in such a way that each partition contai..
[Python] 백슬래시(역슬래시) 입출력
·
Development/Python
백슬래시(\)로 insert 오류 쿠키값을 db에 저장해야할 일이 생겼는데, 쿠키값에 백슬래시(\)가 들어있어서 insert시에 공백으로 입력되는 문제가 발생하였다. \를 \\로 입력하면 되는데 !! python 에서 어떻게 하는지 잘 모르겠어서 삽질을 했다..ㅠ \ => \\ 로 바꾸고 싶었는데 입력 자체가 안되더라💦 코드 작성 php 에서는 내장함수은 addslashes()가 있어서 사용하면 편리했는데, 파이썬도 분명 있을 것 같은데 못 찾았다..😯 아래 처럼 작성해보았는데 역시나 안된다..😮‍💨 (코드는 일단 막 적고 보는 편) 일단 급해서 임의로 코드를 작성했는데.. 더효율적인 방법 알고 계시다면 알려주시면 감사하겠습니다..ㅎ single_backslash = "\\" double_backslas..
01. MySQL 설치 전 작업
·
Development
OpenSSL 설치 2022.03.17 - [개발일기] - 01. OpenSSL 업그레이드 기본 라이브러리 설치 # yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel libtool libtool-l..
[CentOS 7] PHP에 OPCache 설치하기
·
Development/PHP
OPCache는 성능향상을 위해서 사용하는 확장 기능이다. 더보기 PHP는 컴파일 > 실행 > 결과의 프로세스를 거치게 되는데, OPcache는 컴파일된 코드를 바이너리로 메모리에 캐싱해 결과값을 빠르게 얻을 수 있는 역할을 한다. 확장 유틸리티 설치 # yum install yum-utils Opcache 확장 프로그램 설치 # yum install php-opcache PHP 버전 확인 # php -v 실행 결과 opcache.ini 파일 편집 # vi /etc/php.d/10-opcache.ini 다음을 주석처리 해제한다. opcache.enable_cli=1 opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_a..
date 조회 시 유의사항
·
Development/MySql
날짜 조회하다가, 늘 쓰던 between A and B를 사용하였는데 특정 날짜가 안나왔다. 상황 between A and B 사용 where date between '2021-10-01' and '2021-12-31' where date between '2021-10-01' and '2021-12-31' 이렇게 입력했더니 2021-10-01~2021-12-30 일자만 출력 되었다.. where date_format(sd_date,'%Y%m%d')=20211231 분명 조회했을땐 데이터가 있었는데 안나오길래 찾아본결과, 해당 date 칼럼은 datetime 형식으로, 내가 조회할때 시간을 입력하지 않아서 자동으로 00:00:00으로 된 것이다. 그래서 실제로 조회할때의 값은 2021-10-01 00:00..
MySQL 테이블 크기 확인하기
·
Development/MySql
테이블 데이터를 조회하다가, 특정 한 테이블만 속도가 너무느려서 크기를 확인하고자 알아본 쿼리이다. SELECT table_name, table_rows, round(data_length/(1024*1024),2) as 'DATA_SIZE(MB)', round(index_length/(1024*1024),2) as 'INDEX_SIZE(MB)' FROM information_schema.TABLES WHERE table_schema = 'DB_name' -- 조회할 DB 이름 입력 GROUP BY table_name ORDER BY data_length DESC LIMIT 10; -- 길이가 긴 것 부터 LIMIT 10개
[MySQL] update 시 timeout 에러 발생할 때
·
Development/MySql
기존쿼리 select count(*) from Obj.table where date_format(date,'%Y%m%d') between 20201001 and 20210930 and reference in (0,1) and sd_limit = 1; 수정쿼리 select count(*) from Obj.table WHERE date between '2020-10-01' AND '2021-09-30' and reference in (0,1) and sd_limit = 1; date 칼럼은 datetime으로 지정되어있으니 컬럼명 between 'YYYY-mm-dd' and 'YYYY-mm-dd'로 조회하는게 속도에 더 좋다고 하여서 수정하였다. 추가로 reference값은 조회해보니 1인 값은 없어서 re..
toad for MySQL 에러
·
Development/MySql
특정쿼리 실행 시 발생 데이터 수는 10000건 쿼리문은 select * from 테이블명 where a=value and b in ()인데 in 에서 값을 많이줘서 그런가?