第39讲 Perfetto 自动化之如何写SQL查询语句

2024年10月31日 第39讲 Perfetto 自动化之如何写SQL查询语句 极客笔记

本讲是Android Camera性能分析专题的第39讲,我们介Perfetto 自动化之如何写SQL查询语句。

更多资源:

资源 描述
在线课程 极客笔记在线课程
知识星球 星球名称:深入浅出Android Camera
星球ID: 17296815
Wechat 极客笔记圈

SQL基本查询语句

查询所有列的数据

SELECT * FROM thread

查询指定列的数据

SELECT name AS NAME, tid AS TID FROM thread

限制查询结果数量

SELECT * FROM thread LIMIT 5

对查询结果进行分组

SELECT name FROM process GROUP BY name

对查询结果进行排序

SELECT * FROM process ORDER BY pid DESC
SELECT * FROM process ORDER BY pid ASC

SQL条件查询语句

基本条件查询

SELECT * FROM process WHERE name='/system/bin/cameraserver'
SELECT * FROM process WHERE name IN ('com.android.camera2', '/system/bin/cameraserver')

模糊条件查询

SELECT * FROM process WHERE name LIKE '%cam%'

SQL 条件运算符

SQL多表查询

语法:

SELECT column1, column2, ...
FROM tableA
JOIN tableB ON condition;

例子:查询slice name为frame capture所在的进程名和PID:

SELECT slice.name, process.pid, process.name
FROM slice
JOIN process_track ON slice.track_id = process_track.id
JOIN process USING(upid)
WHERE slice.name = 'frame capture'
GROUP BY process.name

等价于

SELECT slice.name, process.pid, process.name
FROM slice
JOIN process_track ON slice.track_id = process_track.id
JOIN process ON process_track.upid = process.upid
WHERE slice.name = 'frame capture'
GROUP BY process.name

本文链接:http://so.lmcjl.com/news/16670/

展开阅读全文