데이터 분석의 명암
최근에 들어서 데이터의 수집과 통계 자료를 통해서 현상을 파악하고 새로운 트렌트를 찾으려는 시도가 많아졌다. 많은 업체에서는 데이터를 기반으로 UX를 분석하기 위해 A/B 테스트를 도입하기도 하고 이를 회사의 장점으로 채용 공고에 소개하는 경우도 많이 있다. 그간 얼마나 주먹구구식의 의사결정이 있었는지는 모르겠지만,… 더 보기 »데이터 분석의 명암
최근에 들어서 데이터의 수집과 통계 자료를 통해서 현상을 파악하고 새로운 트렌트를 찾으려는 시도가 많아졌다. 많은 업체에서는 데이터를 기반으로 UX를 분석하기 위해 A/B 테스트를 도입하기도 하고 이를 회사의 장점으로 채용 공고에 소개하는 경우도 많이 있다. 그간 얼마나 주먹구구식의 의사결정이 있었는지는 모르겠지만,… 더 보기 »데이터 분석의 명암
일단 아무런 문제가 없는 간단한 Entity와 Repository를 만들고, application.yml에 h2 DB에 대한 정보를 적어둔다.
1 2 3 4 5 6 7 8 9 10 |
@Data @Entity public class Member { @Id @GeneratedValue private Long id; @Column(nullable = false) private String name; } |
1 2 |
public interface MemberRepository extends JpaRepository<Member, Long> { } |
1 2 3 4 5 6 7 8 9 |
spring: h2: console: enabled: true jpa: show-sql: true datasource: hikari: jdbc-url: jdbc:h2:mem:testdb;MODE=MySQL; # MODE=MySQL이 굉장히 중요하다 |
그런 후에 아래 테스트를 실행시켜보자.
1 2 3 4 5 6 7 8 9 10 11 12 |
@SpringBootTest class DemoApplicationTests { @Autowired private MemberRepository memberRepository; @Test void test() { memberRepository.save(new Member()); // Entity의 값을 null로 insert함 System.out.println(memberRepository.findAll()); } } |
테스트가 성공하고, 결과값이 나온다. column은 not null로 선언되어 있었다. 그런데 null로 insert가 성공한 것이다.
1 2 3 4 5 6 |
Hibernate: create table member (id bigint not null, name varchar(255) not null, primary key (id)) ... Hibernate: call next value for hibernate_sequence Hibernate: insert into member (name, id) values (?, ?) Hibernate: select member0_.id as id1_0_, member0_.name as name2_0_ from member member0_ [Member(id=1, name=)] |
데이터베이스별 용량 확인
1 2 3 4 5 6 7 8 |
select table_schema as "database name", sum(data_length + index_length) / 1024 / 1024as"size(MB)", sum(data_free) / 1024 / 1024as"free(MB)" from information_schema.TABLES group by table_schema; |
테이블별 용량 확인
1 2 3 4 5 6 7 8 9 10 11 |
select table_schema as "database name", table_name as "table name", sum(data_length + index_length) / 1024 / 1024as size, sum(data_free) / 1024 / 1024as"free(MB)" from information_schema.TABLES group by table_name order by size desc; |
테이블 정보 확인
1 2 |
show table status; select * from information_schema.TABLES; |
오류를 고쳤으면 공유하는 것이 미덕이라 생각되어 적어둠 SpringBoot 2.1.8로 올렸더니 mysql connector에서 오류가 발생하여 고생했는데, implementation(“mysql:mysql-connector-java:8.0.15”) 라고 버전을 명시하니 오류가 사라짐. 현재 최신 버전은 8.0.16인데, 호환성에 문제가 있는 듯. 아래 링크를 보면 MySQL쪽에서 호환성 처리를 해줘야만 된다고 한다. ref. https://stackoverflow.com/questions/56893867/error-connecting-to-memsql-with-mysql-j-connector