Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support Bulk Insert in WriteAsync it is taking time while Iterating to insert #1751

Closed
jitendrajadav opened this issue Jun 20, 2018 · 7 comments

Comments

@jitendrajadav
Copy link

jitendrajadav commented Jun 20, 2018

Add support Bulk Insert in WriteAsync it is taking time while Iterating to insert

I have Xamarin.forms project earlier it was in SQLite now I have converted to realm it taking time to insert bulk data.

@nirinchev
Copy link
Member

Can you be more specific - it would help to have an example of what you're doing and saying "taking time" is too vague - how many records are you inserting and how much time does it take?

@jitendrajadav
Copy link
Author

jitendrajadav commented Jun 20, 2018

Hi @nirinchev I am inserting data like
var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig()); RealmDb.Write(() => { foreach (var item in Collection) { RealmDb.Add(item); } });

it is about to 1000 records is there and time would be 25 seconds in iOS but android taking more than iOS

@nirinchev
Copy link
Member

1000 records shouldn't take so long to insert. Are your objects huge? Can you create a small repro project that we can run locally and profile?

@jitendrajadav
Copy link
Author

Yes Object is huge actually my project has some dependency without I can't create demo repository otherwise I would surely share that.

@nirinchev
Copy link
Member

Can you share the schema of your object at least? How large is the Realm file after the insertion?

@jitendrajadav
Copy link
Author

jitendrajadav commented Jun 20, 2018

please find my schema
`
public class MnfstModel : RealmObject
{
[PrimaryKey]
public string mId { get; set; }
public long EventTypeId { get; set; }
public long Latitude { get; set; }
public long Longitude { get; set; }
public DateTimeOffset SubmittedDate { get; set; }
public DateTimeOffset ShipDate { get; set; }
public string SenderId { get; set; }
public string ReceiverId { get; set; }
public string OwnerName { get; set; }
public int MnfstItemsCount { get; set; }
public IList BrcdModels { get;}
public IList MnfstItems { get; }
public IList NwPlts { get; }
public IList Tags { get; }
public IList ClsBtcs { get; }
public IList NwBtcses { get; }
public bool IsDraft { get; set; }
public bool IsQueue { get; set; }
}

public class BrcdModel : RealmObject
{
    public string Barcode { get; set; }
    public string Icon { get; set; }
    public string TagsStr { get; set; }
    public IList<Tag> Tags { get; }
    public string Page { get; set; }
    public bool IsMtnVerified { get; set; }
    public bool IsScnned { get; set; }
    public Kgs Kgss { get; set; }
    public Plts Pltss { get; set; }
    public KgResponse Response { get; set; }

}
public class Kgs : RealmObject
{
    public IList<string> Contents { get; }
    public IList<string> Sizes { get; }
    public IList<string> Batches { get; }
    public IList<Prtnr> Prtnrs { get; }
    public IList<Location> Locations { get; }
    public IList<MntncItem> MntncItems { get; }
    public IList<SkUs> SkUs { get; }
}

public class Location : RealmObject
{
    public string Name { get; set; }
    public string TypeCode { get; set; }
    public string EntityId { get; set; }
}

public class MntncItem : RealmObject
{
    public long Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public bool IsAlert { get; set; }
    public bool IsAction { get; set; }
    public string DefectType { get; set; }
    public string ActivationMethod { get; set; }
    public DateTimeOffset? DeletedDate { get; set; }
    public bool InUse { get; set; }
    public IList<string> ActivationPrtnrTypes { get;}
}

public class Prtnr : RealmObject
{
    public string PrtnrId { get; set; }
    public IList<DCan> Kgs { get; }
    public string FullName { get; set; }
    public string Address { get; set; }
    public string Address1 { get; set; }
    public string City { get; set; }
    public string State { get; set; }
    public string PostalCode { get; set; }
    public string Country { get; set; }
    public string PhoneNumber { get; set; }
    public string PrtnrTypeName { get; set; }
    public string PrtnrTypeCode { get; set; }
    public string LocationCode { get; set; }
    public double Lat { get; set; }
    public double Lon { get; set; }
    public bool IsInternal { get; set; }
    public bool IsShared { get; set; }
    public bool IsActive { get; set; }
    public bool PrtnrshipIsActive { get; set; }
    public string MstCompanyId { get; set; }
    public string ParentPrtnrId { get; set; }
    public string ParentPrtnrName { get; set; }
    public string SourceKey { get; set; }
    public string LocationStatus { get; set; }
    public long? ComNo { get; set; }
}

public class DCan : RealmObject
{
    public string DCanId { get; set; }
    public string PrtnrId { get; set; }
    public string ID { get; set; }
    public string Altcode { get; set; }
    public long Contents { get; set; }
    public long Batch { get; set; }
    public long Size { get; set; }
    public string Alert { get; set; }
    public long Location { get; set; }
    public IList<long> MntncItems { get; }
    public IList<long> PendingMntncItems { get;}
    public long? Sku { get; set; }
    public long? ContentsSku { get; set; }
}

public class SkUs : RealmObject
{
    public string OwnerName { get; set; }
    public string AssetSkuId { get; set; }
    public string Supplier { get; set; }
    public string SkuId { get; set; }
    public string CompanyId { get; set; }
    public string SkuCode { get; set; }
    public string SkuName { get; set; }
    public string SkuClass { get; set; }
    public string AssetId { get; set; }
    public string SupplierId { get; set; }
    public string Type { get; set; }
    public string Size { get; set; }
    public string Name { get; set; }
    public bool IsRequired { get; set; }
    public bool IsActive { get; set; }
    public string SourceKey { get; set; }
    public string ShortName { get; set; }
    public string AssetSkuId { get; set; }
    public string code { get; set; }
}

public class Plts : RealmObject
{
    public IList<string> Contents { get; }
    public IList<string> PurplePlts { get; }
    public IList<string> Companies { get; }
    public IList<string> Skus { get; }
}

`

@sync-by-unito
Copy link

sync-by-unito bot commented Aug 14, 2023

➤ nirinchev commented:

Closing due to inactivity

@sync-by-unito sync-by-unito bot closed this as completed Aug 14, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants