Skip to content

Instantly share code, notes, and snippets.

@Jwata
Created October 7, 2015 07:32
Show Gist options
  • Save Jwata/7341ee79bc060b2cc1bf to your computer and use it in GitHub Desktop.
Save Jwata/7341ee79bc060b2cc1bf to your computer and use it in GitHub Desktop.

myprofile_settings

SELECT t0.id               c0, 
       t0.first_name       c1, 
       t0.middle_name      c2, 
       t0.last_name        c3, 
       t0.gender           c4, 
       t0.birth_year       c5, 
       t0.job              c6, 
       t0.income           c7, 
       t0.country          c8, 
       t0.zip_code         c9, 
       t0.state            c10, 
       t0.city             c11, 
       t0.address          c12, 
       t0.introduction     c13, 
       t0.telephone_number c14, 
       t0.updated_at       c15, 
       t0.created_at       c16, 
       t0.user_identifier  c17 
FROM   user_profile t0 
WHERE  t0.user_identifier = 'TzTcIITY4CdzbZYrpCpqyPhxZpzUpBWf' 
SELECT t0.id              c0, 
       t0.balance         c1, 
       t0.updated_at      c2, 
       t0.user_identifier c3 
FROM   user_balance t0 
WHERE  t0.user_identifier = 'TzTcIITY4CdzbZYrpCpqyPhxZpzUpBWf' 

myprofile

SELECT t0.id              c0, 
       t0.balance         c1, 
       t0.updated_at      c2, 
       t0.user_identifier c3 
FROM   user_balance t0 
WHERE  t0.user_identifier = 'TzTcIITY4CdzbZYrpCpqyPhxZpzUpBWf' 
SELECT t0.id              c0, 
       t0.campaign_code   c1, 
       t0.serial_code     c2, 
       t0.industry        c3, 
       t0.occupation      c4, 
       t0.company         c5, 
       t0.branch          c6, 
       t0.product_name    c7, 
       t0.product_version c8, 
       t0.extra1          c9, 
       t0.extra2          c10, 
       t0.rants           c11, 
       t0.proposals       c12, 
       t0.empathies       c13, 
       t0.price           c14, 
       t0.status          c15, 
       t0.latitude        c16, 
       t0.longitude       c17, 
       t0.remote_address  c18, 
       t0.user_agent      c19, 
       t0.updated_at      c20, 
       t0.created_at      c21, 
       t0.user_identifier c22 
FROM   rant t0 
WHERE  t0.user_identifier = 'TzTcIITY4CdzbZYrpCpqyPhxZpzUpBWf' 
ORDER  BY t0.created_at DESC 
LIMIT  201 
SELECT Count(*) 
FROM   rant t0 
WHERE  t0.user_identifier = 'TzTcIITY4CdzbZYrpCpqyPhxZpzUpBWf' 
@Jwata
Copy link
Author

Jwata commented Oct 7, 2015

Issue:

  • myprofile_settings
    • user_profile と user_balanceへのアクセスが多い。
      2つのレコードの更新頻度が低いのでバックエンドでキャッシュしたい。
  • myprofile
    • rantを全件取得している
    • order by created_at

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment