Picking a database for a project

polaris · · 459 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hello, I&#39;m learning Go while building a little project on the side. I have to say Go has been awesome to learn in its own right, and an awesome tool for learning how to do more than frontend stuff in JS.</p> <p>I need a db for my project now, and everywhere I look, people say I should pick the right db for the job; only I don&#39;t really know the characteristics of each db. :-(</p> <p>I do know the project though. So maybe if I share it with you awesome people, you can give me some pointers :)</p> <ul> <li>I will not &#34;build&#34; my own data up, starting with nothing.</li> <li>Instead I will get all the data as xml files that I&#39;ll need to parse to structs (once a day&#39;ish).</li> <li>I will never change parts of these structs (say, update the name of some item).</li> <li>There are around 3-4 tables of data that do relate to each other.</li> <li>I will need to make queries into the data. Like &#34;Give me all the red flowers&#34;, or &#34;cars with more than 2 doors&#34;.</li> <li>We are talking &gt;1,000,000 entries.</li> <li>... and many queries /sec.</li> <li>Not sure if it matters, but the entry point will be web.</li> </ul> <p>My initial thought was Postgres because of the relations between the data, but since the data is not built (and validated) by me the performance hit might not be worth it.</p> <p>Next I considered Mongodb because it can handle a lot of data fairly well. But it seems wrong to run back to JS for me.</p> <p>Then, as part of looking into the different dbs, I played around with Boltdb, but a key/value store does not seem correct for queries into random parts of the data. (Would you do that with bloom filters and then run through every single entry in a loop for every single query?)</p> <p>Now, writing this, I wonder if I&#39;m foolish even putting stuff in a db. If I could work with just the raw .xml files?</p> <p>Any help with this would be awesome. I am a little overwhelmed by the number of dbs to pick from.</p> <p>Thanks!</p> <hr/>**评论:**<br/><br/>very-little-gravitas: <pre><p>Just use Postgresql, don&#39;t worry about performance unless you actually see a problem (you won&#39;t). The only hard part will be getting data in (not so hard, just import, convert to sql and insert), after that it&#39;ll be very easy and very fast to search through it. You&#39;re correct in thinking trying to put relational data into a document database will not end well. I think you need the db if you want fast queries over millions of documents. </p></pre>jerf: <pre><p>I&#39;d actually expect performance issues with Postgres, not &#34;it can&#39;t do it&#34; or anything, but just because that is enough data to probably need an index. I recommend <a href="http://use-the-index-luke.com" rel="nofollow">this resource about indexing</a>, as it is designed for use by devs in pretty much exactly this use case.</p> <p>But Postgres is still the right choice here, and it&#39;s hard to overstate the utility of learning how to use relational databases for this task.</p></pre>brentadamson: <pre><p>I agree w/ the others w/ Postgresql. Depending on the data you might want to try Postgresql&#39;s jsonb. I would also recommend using an interface so that if you decide to switch databases later then the transition will be much easier. See <a href="https://appliedgo.net/di/" rel="nofollow">https://appliedgo.net/di/</a></p></pre>Golanq: <pre><p>I guess I&#39;ll go with postgres then. Thanks for the responses guys. And thanks for the link. I need to do some reading up :-)</p></pre>karma_vacuum123: <pre><p>start out with something well-known like Postgres or MySQL</p> <p>you will almost certainly never get anywhere close to the performance limits for these tools given a reasonably well-designed schema and reasonable hardware</p> <p>a decently provisioned MySQL server should scale to thousands of txns per second</p> <p>it will be more important for you to be able to find good help online and good libraries</p></pre>Floooof: <pre><p>Give ElasticSearch a shot. Your updates are once per day, so ACID transaction support isn&#39;t a necessity. It sounds like you&#39;re loading this data only to query it, and your query examples are faceted search terms. If you need to do any sort of merging or upsort to append the daily data files to what&#39;s already present, you may want to load the data into a relational database or other intermediate system of record for pre-processing before building your search indexes in elasticsearch, but if your daily files always contain all the data, just load them into elasticsearch and your project is mostly done. It&#39;s super easy to cluster (if your data or query volume grows) especially with your once daily offline write and 100% read workload. This is exactly what databases such as this were built to handle.</p></pre>Golanq: <pre><p>I seriously thought ElasticSearch was a service and not a db. I&#39;ll do some reading up.</p> <p>Didn&#39;t know the term &#34;faceted search terms&#34;. Thanks! More reading up :)</p> <p>I do need to merge data (if my understanding is correct); say, add the manufactor to the red cars when querying for them.</p> <p>Yes, the data I get is all of the data, and I shouldn&#39;t need to validate it as such.</p> <p>I&#39;ll do some reading up on ElasticSearch and see where that takes me. Sleeping upon this question though, made me realise that exactly because the data gets flushed every day, it wouldn&#39;t be too difficult to change in the future in case I pick the &#34;wrong&#34; option.</p></pre>: <pre><p>[deleted]</p></pre>bass_case: <pre><p>What do you mean how is it overwhelming? Do you live under a rock? There&#39;s been new db&#39;s popping up every month for the last 2 years. It&#39;s certainly overwhelming.</p></pre>: <pre><p>[deleted]</p></pre>Golanq: <pre><p>I think you are forgetting that I am learning as I go. I find it overwhelming because I&#39;m new to dbs in general. I&#39;ve tried a little mongo and tried a little postgres and mysql; but always as the frontend guy that sometimes would make my own endpoint to query for something.</p> <p>Alone in this thread (with a very specific use case), there are three different ones suggested to me, and one of them (elastic search) I thought was a service and not a db.</p></pre>: <pre><p>[deleted]</p></pre>Golanq: <pre><p>I actually went with MySQL for my previous side project (an RSS reader with a web interface) and I&#39;ve been generally happy with it (except that one time where I had to learn about utf8mb4).</p> <p>I think I&#39;ll go with Postgres now though. It seems like a really good &#34;general purpose&#34; db. Has lots of help and documentation. We use it at work already. And I get to use the excellent sqlx library. :)</p></pre>bass_case: <pre><p>I agree with you, many aren&#39;t fit. Yet, many are. One example of this is choosing a time series db. There&#39;s at least 5+ production ready choices out there.</p> <p>In general there are lots of databases these days for a variety of use cases and it IS overwhelming to choose from. Consider the same question from the point of view of choosing the correct ML algorithm for a particular problem. Sure there are various sets of problems like regression / classification / dimensionality / clustering but its really difficult choosing the algorithm that models your data unless you have a high level view / knowledge of all of them. For example inside of the classification problem set you have algo choies like: bayes, kneighbors, svc, ensemble, kernel approx, sgd, and linear svc. Overwhelming!</p></pre>R2A2: <pre><p>MongoDB might be great for this. Document databases are generally a good match for XML. The MGO driver is makes persisting structs super easy. You define struct tags just like with XML/json</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

459 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传