V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
MySQL 5.5 Community Server
MySQL 5.6 Community Server
Percona Configuration Wizard
XtraBackup 搭建主从复制
Great Sites on MySQL
Percona
MySQL Performance Blog
Severalnines
推荐管理工具
Sequel Pro
phpMyAdmin
推荐书目
MySQL Cookbook
MySQL 相关项目
MariaDB
Drizzle
参考文档
http://mysql-python.sourceforge.net/MySQLdb.html
nvhanzhi
V2EX  ›  MySQL

小白求救,也没有熟悉 mysql 的大佬帮我写几个索引啊,跪谢!

  •  
  •   nvhanzhi · 2023-04-29 23:30:16 +08:00 · 1437 次点击
    这是一个创建于 592 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我用插件查出来的,我的 wordpress 排名前几的搜索都很慢,求大佬支援。。。

    SELECT ibz_posts.ID FROM ibz_posts LEFT JOIN ibz_term_relationships ON (ibz_posts.ID = ibz_term_relationships.object_id) WHERE 1=1 AND ( ibz_term_relationships.term_taxonomy_id IN (i) ) AND ((ibz_posts.post_type = s AND (ibz_posts.post_status = s))) AND ( NOT EXISTS (select * from ibz_term_relationships tr inner join ibz_term_taxonomy tt on tr.term_taxonomy_id = tt.term_taxonomy_id where tt.taxonomy = s and ibz_posts.ID = tr.object_id AND tr.term_taxonomy_id IN (i))) ORDER BY ibz_posts.post_date DESC, ibz_posts.ID DESC LIMIT 0, 12

    UPDATE ibz_postmeta SET meta_value = s WHERE post_id = i AND meta_key = s

    SELECT term_id, meta_key, meta_value FROM ibz_termmeta WHERE term_id IN (i, i) ORDER BY meta_id ASC

    SELECT t., tt., tr.object_id FROM ibz_terms AS t INNER JOIN ibz_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN ibz_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN (s, s, s, s, s) AND tr.object_id IN (ilonglist) ORDER BY t.name ASC

    SELECT t., tt., tr.object_id FROM ibz_terms AS t INNER JOIN ibz_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN ibz_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN (s, s, s, s, s) AND tr.object_id IN (ilist) ORDER BY t.name ASC

    SELECT t., tt., tr.object_id FROM ibz_terms AS t INNER JOIN ibz_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN ibz_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN (s, s, s, s, s) AND tr.object_id IN (i, i) ORDER BY t.name ASC

    SELECT t., tt., tr.object_id FROM ibz_terms AS t INNER JOIN ibz_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN ibz_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN (s, s, s, s, s) AND tr.object_id IN (i) ORDER BY t.name ASC

    SELECT t., tt. FROM ibz_terms AS t INNER JOIN ibz_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN ibz_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN (s) AND tr.object_id IN (i) ORDER BY t.name ASC

    3 条回复    2023-05-01 10:35:30 +08:00
    hefish
        1
    hefish  
       2023-04-29 23:38:05 +08:00
    照着 sql 把 where 部分的字段盲加一下,再不行把 ORDER by 字段盲加一下,再不行把 ON 字段的盲加一下。。。
    nvhanzhi
        2
    nvhanzhi  
    OP
       2023-04-30 01:26:55 +08:00
    @hefish 大佬,请帮我写一个做个例子,我完全不懂这个啊,谢谢啦
    RainCats
        3
    RainCats  
       2023-05-01 10:35:30 +08:00
    @nvhanzhi 自己去搜一下 MySQL 的建索引语法,或者借助图形化工具操作一下。。。别啥都等着别人喂给你吃
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5591 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 02:38 · PVG 10:38 · LAX 18:38 · JFK 21:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.