143 Matching Annotations
  1. Last 7 days
  2. Apr 2022
    1. These callbacks are smart enough to run after the final (outer) transaction* is committed. * Usually, there is one real transaction and nested transactions are implemented through savepoints (see, for example, PostgreSQL).

      important qualification: the outer transaction, the (only) real transaction

    1. These callbacks are focused on the transactions, instead of specific model actions.

      At least I think this is talking about this as limitation/problem.

      The limitation/problem being that it's not good/useful for performing after-transaction code only for specific actions.

      But the next sentence "This is beneficial..." seems contradictory, so I'm a bit confused/unclear of what the intention is...

      Looking at this project more, it doesn't appear to solve the "after-transaction code only for specific actions" problem like I initially thought it did (and like https://github.com/grosser/ar_after_transaction does), so I believe I was mistaken. Still not sure what is meant by "instead of specific model actions". Are they claiming that "before_commit_on_create" for example is a "specific model action"? (hardly!) That seems almost identical to the (not specific enough) callbacks provided natively by Rails. Oh yeah, I guess they do point out that Rails 3 adds this functionality, so this gem is only needed for Rails 2.

    1. In this case, the worker process query the newly-created notification before main process commits the transaction, it will raise NotFoundError, because transaction in worker process can't read uncommitted notification from transaction in main process.
    1. Generates the following sql in sqlite3: "SELECT \"patients\".* FROM \"patients\" INNER JOIN \"users\" ON \"users\".\"id\" = \"patients\".\"user_id\" WHERE (\"users\".\"name\" LIKE '%query%')" And the following sql in postgres (notice the ILIKE): "SELECT \"patients\".* FROM \"patients\" INNER JOIN \"users\" ON \"users\".\"id\" = \"patients\".\"user_id\" WHERE (\"users\".\"name\" ILIKE '%query%')" This allows you to join with simplicity, but still get the abstraction of the ARel matcher to your RDBMS.
  3. Mar 2022
    1. # Optionally, you can write a description for the migration, which you can use for # documentation and changelogs. describe 'The _id suffix has been removed from the author property in the Articles API.'
    1. Object hierarchies are very different from relational hierarchies. Relational hierarchies focus on data and its relationships, whereas objects manage not only data, but also their identity and the behavior centered around that data.
    1. If you need to ensure migrations run in a certain order with regular db:migrate, set up Outrigger.ordered. It can be a hash or a proc that takes a tag; either way it needs to return a sortable value: Outrigger.ordered = { predeploy: -1, postdeploy: 1 } This will run predeploys, untagged migrations (implicitly 0), and then postdeploy migrations.
    1. The code will work without exception but it doesn’t set correct association, because the defined classes are under namespace AddStatusToUser. This is what happens in reality: role = AddStatusToUser::Role.create!(name: 'admin') AddStatusToUser::User.create!(nick: '@ka8725', role: role)
    1. this gem promotes writing tests for data migrations providing a way allows to write code that migrates data in separate methods.
    2. having the code migrates data separately covered by proper tests eliminates those pesky situations with outdated migrations or corrupted data.
    1. There are three keys to backfilling safely: batching, throttling, and running it outside a transaction. Use the Rails console or a separate migration with disable_ddl_transaction!.
    2. Active Record creates a transaction around each migration, and backfilling in the same transaction that alters a table keeps the table locked for the duration of the backfill. class AddSomeColumnToUsers < ActiveRecord::Migration[7.0] def change add_column :users, :some_column, :text User.update_all some_column: "default_value" end end
  4. Feb 2022
    1. Okay, so what’s the blockchain? It’s a database. Unlike most databases, it’s not controlled by one entity and it’s not easily rewritten. Instead, it’s a ledger, a permanent, examinable, public database. One can use it to record transactions of various sorts. It would be a really good way to keep track of property records, for example. Instead, we have title insurance, unsearchable folders of deeds in City Hall and often dusty tax records.

      This wrongly assumes that

      • Permanent records are always desirable
      • Accountability undermines corporations
    1. A very visible aspect of the object-relational mismatch is the fact that relational databases don't support inheritance. You want database structures that map clearly to the objects and allow links anywhere in the inheritance structure. Class Table Inheritance supports this by using one database table per class in the inheritance structure.
    1. Tyler Black, MD. (2022, January 4). /1 =-=-=-=-=-=-=- Thread: Mortality in 2020 and myths =-=-=-=-=-=-=- 2020, unsurprisingly, came with excess death. There was an 18% increase in overall mortality, year on year. But let’s dive in a little bit deeper. The @CDCgov has updated WONDER, its mortality database. Https://t.co/DbbvvbTAZQ [Tweet]. @tylerblack32. https://twitter.com/tylerblack32/status/1478501508132048901

  5. Jan 2022
  6. Dec 2021
  7. Sep 2021
  8. Jun 2021
    1. Li, X., Ostropolets, A., Makadia, R., Shoaibi, A., Rao, G., Sena, A. G., Martinez-Hernandez, E., Delmestri, A., Verhamme, K., Rijnbeek, P. R., Duarte-Salles, T., Suchard, M. A., Ryan, P. B., Hripcsak, G., & Prieto-Alhambra, D. (2021). Characterising the background incidence rates of adverse events of special interest for covid-19 vaccines in eight countries: Multinational network cohort study. BMJ, 373, n1435. https://doi.org/10.1136/bmj.n1435

    1. For example, Database Cleaner for a long time was a must-have add-on: we couldn’t use transactions to automatically rollback the database state, because each thread used its own connection; we had to use TRUNCATE ... or DELETE FROM ... for each table instead, which is much slower. We solved this problem by using a shared connection in all threads (via the TestProf extension). Rails 5.1 was released with a similar functionality out-of-the-box.
  9. May 2021
    1. Robert Colvile. (2021, February 16). The vaccine passports debate is a perfect illustration of my new working theory: That the most important part of modern government, and its most important limitation, is database management. Please stick with me on this—It’s much more interesting than it sounds. (1/?) [Tweet]. @rcolvile. https://twitter.com/rcolvile/status/1361673425140543490

  10. Mar 2021
  11. Feb 2021
  12. Jan 2021
    1. IANA Time Zone Database Main time zone database. This is where Moment TimeZone sources its data from.

      every place has a history of different Time Zones because of the geographical, economical, political, religious reasons .These rules are present in IANA Time Zone database. Also it contains rules for Daylight Saving Time (DST) . Checkout the map on this page: https://en.wikipedia.org/wiki/Daylight_saving_time

  13. Dec 2020
    1. Databases If databases data is stored on a ZFS filesystem, it’s better to create a separate dataset with several tweaks: zfs create -o recordsize=8K -o primarycache=metadata -o logbias=throughput -o mountpoint=/path/to/db_data rpool/db_data recordsize: match the typical RDBMSs page size (8 KiB) primarycache: disable ZFS data caching, as RDBMSs have their own logbias: essentially, disabled log-based writes, relying on the RDBMSs’ integrity measures (see detailed Oracle post)
  14. Nov 2020
    1. Interaction with stable storage in the modern world isgenerally mediated by systems that fall roughly into oneof two categories: a filesystem or a database. Databasesassume as much as they can about the structure of thedata they store. The type of any given piece of datais known (e.g., an integer, an identifier, text, etc.), andthe relationships between data are well defined. Thedatabase is the all-knowing and exclusive arbiter of ac-cess to data.Unfortunately, if the user of the data wants more di-rect control over the data, a database is ill-suited. At thesame time, it is unwieldy to interact directly with stablestorage, so something light-weight in between a databaseand raw storage is needed. Filesystems have traditionallyplayed this role. They present a simple container abstrac-tion for data (a file) that is opaque to the system, and theyallow a simple organizational structure for those contain-ers (a hierarchical directory structure)

      Databases and filesystems are both systems which mediate the interaction between user and stable storage.

      Often, the implicit aim of a database is to capture as much as they can about the structure of the data they store. The database is the all-knowing and exclusive arbiter of access to data.

      If a user wants direct access to the data, a database isn't the right choice, but interacting directly with stable storage is too involved.

      A Filesystem is a lightweight (container) abstraction in between a database and raw storage. Filesystems are opaque to the system (i.e. visible only to the user) and allow for a simple, hierarchical organizational structure of directories.

    1. I've spent the last 3.5 years building a platform for "information applications". The key observation which prompted this was that hierarchical file systems didn't work well for organising information within an organisation.However, hierarchy itself is still incredibly valuable. People think in terms of hierarchies - it's just that they think in terms of multiple hierarchies and an item will almost always belong in more than one place in those hierarchies.If you allow users to describe items in the way which makes sense to them, and then search and browse by any of the terms they've used, then you've eliminated almost all the frustrations of a file system. In my experience of working with people building complex information applications, you need: * deep hierarchy for classifying things * shallow hierarchy for noting relationships (eg "parent company") * multi-values for every single field * controlled values (in our case by linking to other items wherever possible) Unfortunately, none of this stuff is done well by existing database systems. Which was annoying, because I had to write an object store.

      Impressed by this comment. It foreshadows what Roam would become:

      • People think in terms of items belonging to multiple hierarchies
      • If you allow users to describe items in a way that makes sense to them and allow them to search and browse by any of the terms they've used, you've solved many of the problems of existing file systems

      What you need to build a complex information system is:

      • Deep hierarchies for classifying things (overlapping hierarchies should be possible)
      • Shallow hierarchies for noting relationships (Roam does this with a flat structure)
      • Multi-values for every single field
      • Controlled values (e.g. linking to other items when possible)
  15. Oct 2020
    1. Image a situation wherein you have just launched your app. But the data of your app is not being properly displayed or you are not able to fetch the data that is being entered by the users. What will be the impression of your app in the user’s mind?

      Many businesses get confused when it comes to choosing the right database for their application. In fact, it is quite crucial to choose the one between SQLite and Realm.

  16. Sep 2020
    1. The Realm is a new database module that is improving the way databases are used and also supports relationships between objects. If you are part of the SQL development world, then you must be familiar with the Realm.
    1. So Memex was first and foremost an extension of human memory and the associative movements that the mind makes through information: a mechanical analogue to an already mechanical model of memory. Bush transferred this idea into information management; Memex was distinct from traditional forms of indexing not so much in its mechanism or content, but in the way it organised information based on association. The design did not spring from the ether, however; the first Memex design incorporates the technical architecture of the Rapid Selector and the methodology of the Analyzer — the machines Bush was assembling at the time.

      How much further would Bush have gone if he had known about graph theory? He is describing a graph database with nodes and edges and a graphical model itself is the key to the memex.

  17. Aug 2020
    1. Allows batch updates by silencing notifications while the fn is running. Example: form.batch(() => { form.change('firstName', 'Erik') // listeners not notified form.change('lastName', 'Rasmussen') // listeners not notified }) // NOW all listeners notified
  18. Jul 2020
  19. Jun 2020
    1. Normalize the database for this case if your data is going to be modified multiple times
    2. normalizing our dabatase will help us. What means normalize? Well, it simply means to separate our information as much as we can

      directly contradicts firebase's official advice: denormalize the structure by duplicating some of the data: https://youtu.be/lW7DWV2jST0?t=378

    1. Denormalization is a database optimization technique in which we add redundant data to one or more tables
    1. Deadlocks are a classic problem in transactional databases, but they are not dangerous unless they are so frequent that you cannot run certain transactions at all. Normally, you must write your applications so that they are always prepared to re-issue a transaction if it gets rolled back because of a deadlock.
    1. transaction calls can be nested. By default, this makes all database statements in the nested transaction block become part of the parent transaction. For example, the following behavior may be surprising: User.transaction do User.create(username: 'Kotori') User.transaction do User.create(username: 'Nemu') raise ActiveRecord::Rollback end end creates both “Kotori” and “Nemu”. Reason is the ActiveRecord::Rollback exception in the nested block does not issue a ROLLBACK. Since these exceptions are captured in transaction blocks, the parent block does not see it and the real transaction is committed.

      How is this okay??

      When would it ever be the desired/intended behavior for a raise ActiveRecord::Rollback to have absolutely no effect? What good is the transaction then??

      What happened to the principle of least surprise?

      Is there any reason we shouldn't just always use requires_new: true?

      If, like they say, the inner transaction "become[s] part of the parent transaction", then if anything, it should roll back the parent transaction too — not roll back nothing.

    2. One workaround is to begin a transaction on each class whose models you alter:
  20. May 2020
    1. I think you should normalize if you feel that introducing update or insert anomalies can severely impact the accuracy or performance of your database application.  If not, then determine whether you can rely on the user to recognize and update the fields together. There are times when you’ll intentionally denormalize data.  If you need to present summarized or complied data to a user, and that data is very time consuming or resource intensive to create, it may make sense to maintain this data separately.

      When to normalize and when to denormalize. The key is to think about UX, in this case the factors are db integrity (don't create errors that annoy users) and speed (don't make users wait for what they want)

    2. Can database normalization be taken too far?  You bet!  There are times when it isn’t worth the time and effort to fully normalize a database.  In our example you could argue to keep the database in second normal form, that the CustomerCity to CustomerPostalCode dependency isn’t a deal breaker.

      Normalization has diminishing returns

    3. Now each column in the customer table is dependent on the primary key.  Also, the columns don’t rely on one another for values.  Their only dependency is on the primary key.

      Columns dependency on the primary key and no dependency on other columns is how you get 2NF and 3NF

    4. A table is in third normal form if: A table is in 2nd normal form. It contains only columns that are non-transitively dependent on the primary key

      3NF Definition

  21. Apr 2020
    1. From a narratological perspective, it would probably be fair to say that most databases are tragic. In their design, the configuration of their user interfaces, the selection of their contents, and the indexes that manage their workings, most databases are limited when set against the full scope of the field of information they seek to map and the knowledge of the people who created them. In creating a database, we fight against the constraints of the universe – the categories we use to sort out the world; the limitations of time and money and technology – and succumb to them.

      databases are tragic!

    1. columnar databases are well-suited for OLAP-like workloads (e.g., data warehouses) which typically involve highly complex queries over all data (possibly petabytes). However, some work must be done to write data into a columnar database. Transactions (INSERTs) must be separated into columns and compressed as they are stored, making it less suited for OLTP workloads. Row-oriented databases are well-suited for OLTP-like workloads which are more heavily loaded with interactive transactions. For example, retrieving all data from a single row is more efficient when that data is located in a single location (minimizing disk seeks), as in row-oriented architectures. However, column-oriented systems have been developed as hybrids capable of both OLTP and OLAP operations, with some of the OLTP constraints column-oriented systems face mediated using (amongst other qualities) in-memory data storage.[6] Column-oriented systems suitable for both OLAP and OLTP roles effectively reduce the total data footprint by removing the need for separate systems

      typical applications (adding new users data, or even retrieving user data) are better done in (standard) row-oriented DB. Typical analytics application, such as even simple AVG(whole column) are much slower because the elements of the same column are stored far away from each other in a traditional row-oriented DB, hence increasing disk-access time.

    2. seek time is incredibly long compared to the other bottlenecks in computers
    3. Operations that retrieve all the data for a given object (the entire row) are slower. A row-based system can retrieve the row in a single disk read, whereas numerous disk operations to collect data from multiple columns are required from a columnar database.