KBlueLeaf commited on
Commit
862f844
1 Parent(s): 8875345

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +4 -14
README.md CHANGED
@@ -36,21 +36,11 @@ Some fields in Post/Tags use my custom enum field to store type/category or some
36
  * 4: meta
37
 
38
  #### Tag List
39
- SQLite doesn't support any arrayfield or many-to-many relationship natively.<br>
40
- So I use a custom TextField to store ids of tags belongs to a Post.
 
41
 
42
- The basic idea is to use 2 unique symbol for start/end of the number. And use 36-base number<br>
43
- (python support converting n-base number into integer natively, numpy have utils to convert integer into n-base number)
44
-
45
- I use $xxx# format, so when you want to utilize the FTS table to search tag_list, use $\<36-base number\># to find if the tag is in the tag-list.
46
-
47
- For example:<br>
48
- The code in profiling.py use $6KMR# which is 306675 under base-36.<br>
49
- So the profiling.py is doing "fetch all the Post object which have 'umamusume' tag in their tag list"<br>
50
- **If you can ensure the tag type, you can specific the tag_list_\<type\> instead of full tag_list for more efficiency**
51
-
52
- ## Profiling
53
- A test script for showing why I use FTS.
54
 
55
 
56
  #### Utils
 
36
  * 4: meta
37
 
38
  #### Tag List
39
+ I use peewee ManyToManyField to implement the Tag List things. Which utilize a through model which have all the pair of Tag and Post<br>
40
+ Since it is very likely we will want to use Tag to query posts, so many-to-many is better.<br>
41
+ The con of this design is the database file will be 1.5x larger than before(we have 0.25B entries for the post-tag pairs), but the query speed become 2~3x faster, so I think it is acceptable.
42
 
43
+ After done some checking, I can ensure that all the "categorical tag list" can be done by full list + filter, and that is how I done it now. Check the db.py for more details.
 
 
 
 
 
 
 
 
 
 
 
44
 
45
 
46
  #### Utils