我目前希望存储来自大约 100/200k 用户的大约 350 万张照片.我只在 aws 上使用 mysql 数据库.我的问题是关于存储照片参考的最有效方法.我只知道两种方法,我正在寻找专家意见.
I'm currently looking to store approximately 3.5 million photo's from approximately 100/200k users. I'm only using a mysql database on aws. My question is in regards to the most efficient way to store the photo reference. I'm only aware of two ways and I'm looking for an expert opinion.
选择A
一个带有 photo_url 列的用户表,在该列中,我将构建一个逗号分隔的照片列表,该列表同时保持名称和排序顺序.业务逻辑将处理从照片名称中提取路径并附加照片大小.缺点是处理费用.
A user table with a photo_url column, in that column I would build a comma separated list of photo's that both maintain the name and sort order. The business logic would handle extracting the path from the photo name and append photo size. The downside is the processing expense.
数据库示例
"0ea102, e435b9, etc"
业务逻辑将根据照片名称构建以下网址
Business logic would build the following urls from photo name
/0e/a1/02.jpg
/0e/a1/02_thumb.jpg
/e4/35/b9.jpg
/e4/35/b9_thumb.jpg
选择 B - 关系表连接到用户表上,包含以下字段.我只是担心我可能有潜在的数据库性能问题.
Choice B - Relational Table joined on user table with the following fields. I'm just concerned I may have potential database performance issues.
pk
user_id
photo_url_800
photo_url_150
photo_url_45
order
有人对更好的解决方案有什么建议吗?
Does anybody have any suggestions on the better solution?
最好和最常见的答案是:选择 B - 使用以下字段连接到用户表上的关系表.
The best and most common answer would be: choice B - Relational Table joined on user table with the following fields.
id
order
user_id
desc
photo_url_800
photo_url_150
photo_url_45
date_uploaded
或混合,其中,您单独存储文件名,并使用业务逻辑层添加照片目录.
Or a hybrid, wherein, you store the file names individually and add the photo directory with your business logic layer.
我的分析,你的第一个选择是一种不好的做法.数据库中不建议使用逗号分隔的字段.您很难更新这些字段并为其添加说明.
My analysis, your first option is a bad practice. Comma separated fields are not advisable for database. It would be difficult for you to update these fields and add description on it.
关于表优化,您可能希望查看以下文章:
Regarding the table optimization, you might want to see these articles:
这篇关于在数据库中存储照片参考的最有效方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何有效地使用窗口函数根据 N 个先前值来决定How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函数根据
在“GROUP BY"中重用选择表达式的结果;条款reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用选择表达式的结果;条款?)
Pyspark DataFrameWriter jdbc 函数的 ignore 选项是忽略整Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函数的 ig
使用 INSERT INTO table ON DUPLICATE KEY 时出错,使用 Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 时出错,使用 for 循环数组
pyspark mysql jdbc load 调用 o23.load 时发生错误 没有合pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 调用 o23.load 时发生错误 没有合适的
如何将 Apache Spark 与 MySQL 集成以将数据库表作为How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何将 Apache Spark 与 MySQL 集成以将数据库表作为